~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=E0211,E0213

"""Question message interface."""

__metaclass__ = type

__all__ = [
    'IQuestionMessage',
    ]

from zope.schema import (
    Bool,
    Choice,
    Field,
    Int,
    )

from canonical.launchpad import _
from canonical.launchpad.interfaces.message import IMessage
from lp.answers.enums import (
    QuestionAction,
    QuestionStatus,
    )


class IQuestionMessage(IMessage):
    """A message part of a question.

    It adds attributes to the IMessage interface.
    """
    # This is really an Object field with schema=IQuestion, but that
    # would create a circular dependency between IQuestion
    # and IQuestionMessage
    question = Field(
        title=_("The question related to this message."),
        description=_("An IQuestion object."), required=True, readonly=True)

    action = Choice(
        title=_("Action operated on the question by this message."),
        required=True, readonly=True, default=QuestionAction.COMMENT,
        vocabulary=QuestionAction)

    new_status = Choice(
        title=_("Question status after message"),
        description=_("The status of the question after the transition "
        "related the action operated by this message."), required=True,
        readonly=True, default=QuestionStatus.OPEN,
        vocabulary=QuestionStatus)
    index = Int(
        title=_("Message index."),
        description=_("The messages index in the question's list of "
        "messages."),
        readonly=True)
    visible = Bool(
        title=_("Message visibility."),
        description=_("Whether or not the message is visible."),
        readonly=True)