~launchpad-pqm/launchpad/devel

8687.15.11 by Karl Fogel
Add the copyright header block to files under lib/lp/answers/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
4983.1.1 by Curtis Hovey
Added lint exceptions to __init__.py and interface/*.py.
4
# pylint: disable-msg=E0211,E0213
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
5
6
"""Question enumerations."""
7
4611.5.8 by Curtis Hovey
Added comment as to why question enums are in a separate file.
8
# Enums are kept separated from the classes that use them to avoid
9
# circular imports. Notably, QuestonAction and QuestionStatus are
10
# used by most of the schemas for question classes.
11
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
12
__all__ = [
13
    'QuestionAction',
12919.3.4 by Curtis Hovey
Added QuestionJobType to classify IQuestionJobs.
14
    'QuestionJobType',
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
15
    'QuestionParticipation',
16
    'QuestionPriority',
12928.2.12 by Curtis Hovey
Added QuestionRecipientSet so that processes can state who should receive emails.
17
    'QuestionRecipientSet',
12915.5.2 by Curtis Hovey
Copied QUESTION_STATUS_DEFAULT_SEARCH to enums.
18
    'QUESTION_STATUS_DEFAULT_SEARCH',
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
19
    'QuestionSort',
20
    'QuestionStatus',
21
    ]
22
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
23
from lazr.enum import (
24
    DBEnumeratedType,
25
    DBItem,
26
    EnumeratedType,
27
    Item,
28
    )
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
29
30
31
class QuestionAction(DBEnumeratedType):
32
    """An enumeration of the possible actions done on a question.
33
34
    This enumeration is used to tag the action done by a user with
35
    each QuestionMessage. Most of these action indicates a status change
36
    on the question.
37
    """
38
39
    REQUESTINFO = DBItem(10, """
40
        Request for more information
41
42
        This message asks for more information about the question.
43
        """)
44
45
    GIVEINFO = DBItem(20, """
46
        Give more information
47
48
        In this message, the submitter provides more information about the
49
        question.
50
        """)
51
52
    COMMENT = DBItem(30, """
53
        Comment
54
55
        User commented on the message. This is use for example for messages
56
        added to a question in the SOLVED state.
57
        """)
58
59
    ANSWER = DBItem(35, """
60
        Answer
61
62
        This message provides an answer to the question.
63
        """)
64
65
    CONFIRM = DBItem(40, """
66
        Confirm
67
68
        This message confirms that an answer solved the question.
69
        """)
70
71
    REJECT = DBItem(50, """
72
        Reject
73
74
        This message rejects a question as invalid.
75
        """)
76
77
    EXPIRE = DBItem(70, """
78
        Expire
79
80
        Automatic message created when the question is expired.
81
        """)
82
83
    REOPEN = DBItem(80, """
84
        Reopen
85
86
        Message from the submitter that reopens the question while providing
87
        more information.
88
        """)
89
90
    SETSTATUS = DBItem(90, """
91
        Change status
92
93
        Message from an administrator that explain why the question status
94
        was changed.
95
        """)
96
97
12919.3.4 by Curtis Hovey
Added QuestionJobType to classify IQuestionJobs.
98
class QuestionJobType(DBEnumeratedType):
99
    """Values that IQuestionJob.job_type can take."""
100
101
    EMAIL = DBItem(0, """
102
        Question email notification
103
104
        Notify question subscribers about a question via email.
105
        """)
106
107
12928.2.12 by Curtis Hovey
Added QuestionRecipientSet so that processes can state who should receive emails.
108
class QuestionRecipientSet(EnumeratedType):
109
    """The kinds of recipients who will receive notification."""
110
111
    ASKER = Item("""
112
        Asker
113
114
        The person who asked the question.
115
        """)
116
117
    SUBSCRIBER = Item("""
118
        Subscriber
119
120
        The question's direct and indirect subscribers, exception for
121
        the asker.
122
        """)
123
124
    ASKER_SUBSCRIBER = Item("""
125
        Asker and Subscriber
126
127
        The question's direct and indirect subscribers, including the asker.
128
        """)
129
130
    CONTACT = Item("""
131
        Contact
132
133
        All the answer contacts for the question's target.
134
        """)
135
136
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
137
class QuestionParticipation(EnumeratedType):
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
138
    """The different ways a person can be involved in a question.
139
140
    This enumeration is part of the IPerson.searchTickets() API.
141
    """
142
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
143
    OWNER = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
144
        Owner
145
146
        The person created the question.
147
        """)
148
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
149
    SUBSCRIBER = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
150
        Subscriber
151
152
        The person subscribed to the question.
153
        """)
154
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
155
    ASSIGNEE = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
156
        Assignee
157
158
        The person is assigned to the question.
159
        """)
160
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
161
    COMMENTER = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
162
        Commenter
163
164
        The person commented on the question.
165
        """)
166
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
167
    ANSWERER = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
168
        Answerer
169
170
        The person answered the question.
171
        """)
172
173
174
class QuestionPriority(DBEnumeratedType):
175
    """The Priority with a Question must be handled.
176
10342.1.3 by Brad Crittenden
prioritise -> prioritize
177
    This enum is used to prioritize work done in the Launchpad Answert Tracker
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
178
    management system.
179
    """
180
181
    WISHLIST = DBItem(0, """
182
        Wishlist
183
184
        This question is really a request for a new feature. We will not take
185
        it further as a question, it should be closed, and a specification
186
        created and managed in the Launchpad Specification tracker.
187
        """)
188
189
    NORMAL = DBItem(10, """
190
        Normal
191
192
        This question is of normal priority. We should respond to it in due
193
        course.
194
        """)
195
196
    HIGH = DBItem(70, """
197
        High
198
199
        This question has been flagged as being of higher than normal
10342.1.3 by Brad Crittenden
prioritise -> prioritize
200
        priority. It should always be prioritized over a "normal" question.
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
201
        """)
202
203
    EMERGENCY = DBItem(90, """
204
        Emergency
205
206
        This question is classed as an emergency. No more than 5% of
207
        questions should fall into this category. Support engineers should
208
        ensure that there is somebody on this problem full time until it is
209
        resolved, or escalate it to the core technical and management team.
210
        """)
211
212
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
213
class QuestionSort(EnumeratedType):
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
214
    """An enumeration of the valid question search sort order.
215
216
    This enumeration is part of the ITicketTarget.searchTickets() API. The
217
    titles are formatted for nice display in browser code.
218
    """
219
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
220
    RELEVANCY = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
221
    by relevancy
222
223
    Sort by relevancy of the question toward the search text.
224
    """)
225
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
226
    STATUS = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
227
    by status
228
229
    Sort questions by status: Open, Needs information, Answered, Solved,
230
    Expired, Invalid.
231
232
    NEWEST_FIRST should be used as a secondary sort key.
233
    """)
234
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
235
    NEWEST_FIRST = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
236
    newest first
237
238
    Sort questions from newest to oldest.
239
    """)
240
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
241
    OLDEST_FIRST = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
242
    oldest first
243
244
    Sort questions from oldset to newest.
245
    """)
246
4611.5.2 by Curtis Hovey
Converted the FaqSort, QuestionSort, and QuestionParticipation enums
247
    RECENT_OWNER_ACTIVITY = Item("""
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
248
    recently updated first
249
12915.5.2 by Curtis Hovey
Copied QUESTION_STATUS_DEFAULT_SEARCH to enums.
250
    Sort questions that received new information from the owner first.
4611.5.1 by Curtis Hovey
Moved questions enumerations from lp.dbschema to
251
    """)
252
253
254
class QuestionStatus(DBEnumeratedType):
255
    """The current status of a Question.
256
257
    This enum tells us the current status of the question.
258
259
    The lifecycle of a question is documented in
260
    https://help.launchpad.net/QuestionLifeCycle, so remember
261
    to update that document for any pertinent changes.
262
    """
263
264
    OPEN = DBItem(10, """
265
        Open
266
267
        The question is waiting for an answer. This could be a new question
268
        or a question where the given answer was refused by the submitter.
269
        """)
270
271
    NEEDSINFO = DBItem(15, """
272
        Needs information
273
274
        A user requested more information from the submitter. The question
275
        will be moved back to the OPEN state once the submitter provides the
276
        answer.
277
        """)
278
279
    ANSWERED = DBItem(18, """
280
        Answered
281
282
        An answer was given on this question. We assume that the answer
283
        is the correct one. The user will post back changing the question's
284
        status back to OPEN if that is not the case.
285
        """)
286
287
    SOLVED = DBItem(20, """
288
        Solved
289
290
        The submitter confirmed that an answer solved his question.
291
        """)
292
293
    EXPIRED = DBItem(25, """
294
        Expired
295
296
        The question has been expired after 15 days without comments in the
297
        OPEN or NEEDSINFO state.
298
        """)
299
300
    INVALID = DBItem(30, """
301
        Invalid
302
303
        This question isn't a valid question. It could be a duplicate
304
        question, spam or anything that should not appear in the
305
        Answer Tracker.
306
        """)
12915.5.2 by Curtis Hovey
Copied QUESTION_STATUS_DEFAULT_SEARCH to enums.
307
308
13041.2.20 by Curtis Hovey
Reverted QUESTION_STATUS_DEFAULT_SEARCH to a tuple.
309
QUESTION_STATUS_DEFAULT_SEARCH = (
12915.5.2 by Curtis Hovey
Copied QUESTION_STATUS_DEFAULT_SEARCH to enums.
310
    QuestionStatus.OPEN, QuestionStatus.NEEDSINFO, QuestionStatus.ANSWERED,
13041.2.20 by Curtis Hovey
Reverted QUESTION_STATUS_DEFAULT_SEARCH to a tuple.
311
    QuestionStatus.SOLVED)