~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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# 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

"""Interfaces for CodeOfConduct (CoC) and related classes.

https://launchpad.canonical.com/CodeOfConduct
"""

__metaclass__ = type

__all__ = [
    'ICodeOfConduct',
    'ISignedCodeOfConduct',
    'ICodeOfConductSet',
    'ISignedCodeOfConductSet',
    'ICodeOfConductConf',
    ]

from zope.interface import (
    Attribute,
    Interface,
    )
from zope.schema import (
    Bool,
    Choice,
    Datetime,
    Int,
    Text,
    )

from canonical.launchpad import _


class ICodeOfConduct(Interface):
    """Pristine Code of Conduct content."""

    version = Attribute("CoC Release Version")
    title = Attribute("CoC Release Title")
    content = Attribute("CoC File Content")
    current = Attribute("True if the release is the current one")
    datereleased = Attribute("The date it was released")


class ISignedCodeOfConduct(Interface):
    """The Signed Code of Conduct."""

    id = Int(title=_("Signed CoC ID"),
             required=True,
             readonly=True
             )

    owner = Choice(
        title=_('Owner'), required=True, vocabulary='ValidOwner',
        description=_(
            """The person who signed the code of conduct by mail or fax."""
        )
        )

    signedcode = Text(title=_("Signed Code"))

    signingkey = Choice(title=_('Signing OpenPGP Key'),
                        description=_("""OpenPGP key ID used to sign the
                        document. It must be valid inside the Launchpad
                        context."""),
                        vocabulary='ValidGPGKey',
                        required=True
                        )

    datecreated = Datetime(title=_("Date Created"),
                           description=_("Original Request Timestamp")
                           )

    recipient = Int(title=_("Recipient"),
                    description=_("Person Authorizing.")
                    )

    admincomment = Text(
        title=_("Admin Comment"),
        description=_("Admin comment, to e.g. describe the reasons why "
                      "this registration was approved or rejected.")
        )

    active = Bool(title=_("Active"),
                  description=_("Whether or not this Signed CoC "
                                "is considered active.")
                  )


    displayname = Attribute("Fancy Title for CoC.")

    def sendAdvertisementEmail(subject, content):
        """Send Advertisement email to signature owner preferred address
        containing arbitrary content and subject.
        """


# Interfaces for containers
class ICodeOfConductSet(Interface):
    """Unsigned (original) Codes of Conduct container."""

    title = Attribute('Page Title propose')
    current_code_of_conduct = Attribute('The current Code of Conduct')

    def __getitem__(version):
        """Get a original CoC Release by its version

        The version 'console' is a special bind for 'Adminitrative Console
        Interface via ISignedCodeOfConductSet.
        If the requested version was not found in the filesystem, it returns
        None, generating a NotFoundError.
        """

    def __iter__():
        """Iterate through the original CoC releases in this set."""


class ISignedCodeOfConductSet(Interface):
    """A container for Signed CoC."""

    title = Attribute('Page Title propose')

    def __getitem__(id):
        """Get a Signed CoC by id."""

    def __iter__():
        """Iterate through the Signed CoC in this set."""

    def verifyAndStore(user, signedcode):
        """Verify and Store a Signed CoC."""

    def searchByDisplayname(displayname, searchfor=None):
        """Search SignedCoC by Owner.displayname"""

    def searchByUser(user_id, active=True):
        """Search SignedCoC by Owner.id, return only the active ones by
        default.
        """

    def modifySignature(sign_id, recipient, admincomment, state):
        """Modify a Signed CoC."""

    def acknowledgeSignature(user, recipient):
        """Acknowledge a paper submitted Signed CoC."""

    def getLastAcceptedDate():
        """Return a datetime object corresponding to the last accepted date
        of Code of Conduct Signature.
        """

class ICodeOfConductConf(Interface):
    """Component to store the CoC Configuration."""

    path = Attribute("CoCs FS path")
    prefix = Attribute("CoC Title Prefix")
    currentrelease = Attribute("Current CoC release")
    datereleased = Attribute("Date when Current CoC was released")