~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
61
62
63
# 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

"""Specification subscription interfaces."""

__metaclass__ = type

__all__ = [
    'ISpecificationSubscription',
    ]

from lazr.restful.declarations import (
    call_with,
    export_as_webservice_entry,
    export_read_operation,
    operation_for_version,
    REQUEST_USER,
    )
from zope.interface import (
    Attribute,
    Interface,
    )
from zope.schema import (
    Bool,
    Int,
    )

from canonical.launchpad import _
from lp.services.fields import PersonChoice


class ISpecificationSubscription(Interface):
    """A subscription for a person to a specification."""

    export_as_webservice_entry(publish_web_link=False, as_of='devel')

    id = Int(
        title=_('ID'), required=True, readonly=True)
    person = PersonChoice(
            title=_('Subscriber'), required=True,
            vocabulary='ValidPersonOrTeam', readonly=True,
            description=_(
            'The person you would like to subscribe to this blueprint. '
            'They will be notified of the subscription by e-mail.')
            )
    personID = Attribute('db person value')
    specification = Int(title=_('Specification'), required=True,
        readonly=True)
    specificationID = Attribute('db specification value')
    essential = Bool(title=_('Participation essential'), required=True,
        description=_('Check this if participation in the design and '
        'discussion of the feature is essential. This will '
        'cause the meeting scheduler to try to ensure that this person '
        'attends meetings about this feature.'),
        default=False)

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("devel")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the specification?"""