~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/interfaces/question.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-17 01:49:32 UTC
  • mfrom: (13041.2.27 answers-api-2)
  • Revision ID: launchpad@pqm.canonical.com-20110517014932-d97eobi9byvedefn
[r=benji][bug=782093] Export IQuestionCollection methods and
        IQuestionMessage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    operation_parameters,
26
26
    REQUEST_USER,
27
27
    )
 
28
from lazr.restful.fields import (
 
29
    CollectionField,
 
30
    Reference,
 
31
    ReferenceChoice,
 
32
    )
 
33
 
28
34
from zope.interface import (
29
35
    Attribute,
30
36
    Interface,
34
40
    Choice,
35
41
    Datetime,
36
42
    Int,
37
 
    List,
38
43
    Object,
39
44
    Text,
40
45
    TextLine,
50
55
from lp.answers.interfaces.questiontarget import IQuestionTarget
51
56
from lp.registry.interfaces.role import IHasOwner
52
57
from lp.services.fields import PublicPersonChoice
 
58
from lp.services.worlddata.interfaces.language import ILanguage
53
59
 
54
60
 
55
61
class InvalidQuestionStateError(Exception):
73
79
        title=_('Summary'), required=True, description=_(
74
80
        "A one-line summary of the issue or problem.")),
75
81
        as_of="devel")
76
 
    description = Text(
 
82
    description = exported(Text(
77
83
        title=_('Description'), required=True, description=_(
78
84
        "Include as much detail as possible: what "
79
85
        u"you\N{right single quotation mark}re trying to achieve, what steps "
80
 
        "you take, what happens, and what you think should happen instead."))
 
86
        "you take, what happens, and what you think should happen instead.")),
 
87
        as_of="devel")
81
88
    status = exported(Choice(
82
89
        title=_('Status'), vocabulary=QuestionStatus,
83
90
        default=QuestionStatus.OPEN, readonly=True),
87
94
        default=QuestionPriority.NORMAL)
88
95
    # XXX flacoste 2006-10-28: It should be more precise to define a new
89
96
    # vocabulary that excludes the English variants.
90
 
    language = Choice(
91
 
        title=_('Language'), vocabulary='Language',
92
 
        description=_('The language in which this question is written.'))
 
97
    language = exported(ReferenceChoice(
 
98
        title=_('Language'), vocabulary='Language', schema=ILanguage,
 
99
        description=_('The language in which this question is written.')),
 
100
        as_of="devel")
93
101
    owner = exported(PublicPersonChoice(
94
102
        title=_('Owner'), required=True, readonly=True,
95
103
        vocabulary='ValidPersonOrTeam'),
107
115
        vocabulary='ValidPersonOrTeam'),
108
116
        as_of="devel",
109
117
        readonly=True)
110
 
    answer = Object(
 
118
    answer = exported(Reference(
111
119
        title=_('Answer'), required=False,
112
120
        description=_("The IQuestionMessage that contains the answer "
113
121
            "confirmed by the owner as providing a solution to his problem."),
114
 
            schema=IQuestionMessage)
115
 
    datecreated = Datetime(
116
 
        title=_('Date Created'), required=True, readonly=True)
117
 
    datedue = Datetime(
 
122
        schema=IQuestionMessage),
 
123
        readonly=True, as_of="devel")
 
124
    datecreated = exported(Datetime(
 
125
        title=_('Date Created'), required=True, readonly=True),
 
126
        exported_as='date_created', readonly=True, as_of="devel")
 
127
    datedue = exported(Datetime(
118
128
        title=_('Date Due'), required=False, default=None,
119
129
        description=_(
120
 
            "The date by which we should have resolved this question."))
121
 
    datelastquery = Datetime(
 
130
            "The date by which we should have resolved this question.")),
 
131
        exported_as='date_due', readonly=True, as_of="devel")
 
132
    datelastquery = exported(Datetime(
122
133
        title=_("Date Last Queried"), required=True,
123
134
        description=_("The date on which we last heard from the "
124
 
        "customer (owner)."))
125
 
    datelastresponse = Datetime(
 
135
        "customer (owner).")),
 
136
       exported_as='date_last_query',  readonly=True, as_of="devel")
 
137
    datelastresponse = exported(Datetime(
126
138
        title=_("Date last Responded"),
127
139
        required=False,
128
140
        description=_("The date on which we last communicated "
129
141
        "with the customer. The combination of datelastquery and "
130
 
        "datelastresponse tells us in whose court the ball is."))
131
 
    date_solved = Datetime(title=_("Date Answered"), required=False,
 
142
        "datelastresponse tells us in whose court the ball is.")),
 
143
        exported_as='date_last_response', readonly=True, as_of="devel")
 
144
    date_solved = exported(Datetime(title=_("Date Answered"), required=False,
132
145
        description=_(
133
146
            "The date on which the question owner confirmed that the "
134
 
            "question is Solved."))
 
147
            "question is Solved.")),
 
148
        exported_as='date_solved', readonly=True, as_of="devel")
135
149
    product = Choice(
136
150
        title=_('Upstream Project'), required=False,
137
151
        vocabulary='Product',
150
164
        title=_('Status Whiteboard'), required=False,
151
165
        description=_('Up-to-date notes on the status of the question.'))
152
166
    # other attributes
153
 
    target = Object(title=_('Project'), required=True, schema=IQuestionTarget,
 
167
    target = exported(Reference(
 
168
        title=_('Project'), required=True, schema=IQuestionTarget,
154
169
        description=_('The distribution, source package, or product the '
155
 
                      'question pertains to.'))
156
 
 
 
170
                      'question pertains to.')),
 
171
        as_of="devel")
157
172
    faq = Object(
158
173
        title=_('Linked FAQ'),
159
174
        description=_('The FAQ document containing the long answer to this '
165
180
        'The set of subscriptions to this question.')
166
181
    reopenings = Attribute(
167
182
        "Records of times when this question was reopened.")
168
 
    messages = List(
 
183
    messages = exported(CollectionField(
169
184
        title=_("Messages"),
170
185
        description=_(
171
186
            "The list of messages that were exchanged as part of this "
172
187
            "question , sorted from first to last."),
173
 
        value_type=Object(schema=IQuestionMessage),
174
 
        required=True, default=[], readonly=True)
 
188
        value_type=Reference(schema=IQuestionMessage),
 
189
        required=True, default=[], readonly=True),
 
190
        as_of='devel')
175
191
 
176
192
    # Workflow methods
177
193
    def setStatus(user, new_status, comment, datecreated=None):