~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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=E0211,E0213

"""ProjectGroup-related interfaces for Launchpad."""

__metaclass__ = type

__all__ = [
    'IProjectGroup',
    'IProjectGroupPublic',
    'IProjectGroupSeries',
    'IProjectGroupSet',
    ]

from lazr.restful.declarations import (
    collection_default_content,
    export_as_webservice_collection,
    export_as_webservice_entry,
    export_read_operation,
    exported,
    operation_parameters,
    operation_returns_collection_of,
    )
from lazr.restful.fields import (
    CollectionField,
    Reference,
    ReferenceChoice,
    )
from zope.interface import (
    Attribute,
    Interface,
    )
from zope.schema import (
    Bool,
    Datetime,
    Int,
    Object,
    Text,
    TextLine,
    )

from canonical.launchpad import _
from canonical.launchpad.interfaces.launchpad import (
    IHasIcon,
    IHasLogo,
    IHasMugshot,
    )
from lp.app.interfaces.headings import IRootContext
from lp.app.interfaces.launchpad import IServiceUsage
from lp.app.validators.name import name_validator
from lp.blueprints.interfaces.specificationtarget import IHasSpecifications
from lp.blueprints.interfaces.sprint import IHasSprints
from lp.bugs.interfaces.bugtarget import (
    IHasBugs,
    IHasOfficialBugTags,
    )
from lp.bugs.interfaces.bugtracker import IBugTracker
from lp.bugs.interfaces.structuralsubscription import (
    IStructuralSubscriptionTarget,
    )
from lp.code.interfaces.branchvisibilitypolicy import (
    IHasBranchVisibilityPolicy,
    )
from lp.code.interfaces.hasbranches import (
    IHasBranches,
    IHasMergeProposals,
    )
from lp.registry.interfaces.announcement import IMakesAnnouncements
from lp.registry.interfaces.karma import IKarmaContext
from lp.registry.interfaces.milestone import (
    ICanGetMilestonesDirectly,
    IHasMilestones,
    )
from lp.registry.interfaces.pillar import IPillar
from lp.registry.interfaces.role import (
    IHasAppointedDriver,
    IHasDrivers,
    IHasOwner,
    )
from lp.services.fields import (
    IconImageUpload,
    LogoImageUpload,
    MugshotImageUpload,
    PillarNameField,
    PublicPersonChoice,
    Summary,
    Title,
    URIField,
    )
from lp.translations.interfaces.translationpolicy import ITranslationPolicy


class ProjectNameField(PillarNameField):

    @property
    def _content_iface(self):
        return IProjectGroup


class IProjectGroupModerate(IPillar):
    """IProjectGroup attributes used with launchpad.Moderate permission."""
    reviewed = exported(
        Bool(
            title=_('Reviewed'), required=False,
            description=_("Whether or not this project group has been "
                          "reviewed.")))
    name = exported(
        ProjectNameField(
            title=_('Name'),
            required=True,
            description=_(
                "A unique name, used in URLs, identifying the project "
                "group.  All lowercase, no special characters. "
                "Examples: apache, mozilla, gimp."),
            constraint=name_validator))


class IProjectGroupPublic(
    ICanGetMilestonesDirectly, IHasAppointedDriver, IHasBranches, IHasBugs,
    IHasDrivers, IHasBranchVisibilityPolicy, IHasIcon, IHasLogo,
    IHasMergeProposals, IHasMilestones, IHasMugshot,
    IHasOwner, IHasSpecifications, IHasSprints, IMakesAnnouncements,
    IKarmaContext, IRootContext, IHasOfficialBugTags, IServiceUsage):
    """Public IProjectGroup properties."""

    id = Int(title=_('ID'), readonly=True)

    owner = exported(
        PublicPersonChoice(
            title=_('Maintainer'),
            required=True,
            vocabulary='ValidOwner',
            description=_("Project group owner. Must be either a "
                          "Launchpad Person or Team.")))

    registrant = exported(
        PublicPersonChoice(
            title=_('Registrant'),
            required=True,
            readonly=True,
            vocabulary='ValidPersonOrTeam',
            description=_("Project group registrant. Must be a valid "
                          "Launchpad Person.")))

    displayname = exported(
        TextLine(
            title=_('Display Name'),
            description=_(
                "Appropriately capitalised, "
                'and typically ending in "Project". '
                "Examples: the Apache Project, the Mozilla Project, "
                "the Gimp Project.")),
        exported_as="display_name")

    title = exported(
        Title(
            title=_('Title'),
            description=_("The full name of the project group, "
                          "which can contain spaces, special characters, "
                          "etc.")))

    summary = exported(
        Summary(
            title=_('Project Group Summary'),
            description=_(
                "A short paragraph to introduce the project group's work.")))

    description = exported(
        Text(
            title=_('Description'),
            description=_(
                "Details about the project group's work, goals, and "
                "how to contribute. Use plain text, paragraphs are preserved "
                "and URLs are linked in pages. Don't repeat the Summary.")))

    datecreated = exported(
        Datetime(
            title=_('Date Created'),
            description=_(
                "The date this project group was created in Launchpad."),
            readonly=True),
        exported_as="date_created")

    driver = exported(
        PublicPersonChoice(
            title=_("Driver"),
            description=_(
                "This is a project group-wide appointment. Think carefully "
                "here! This person or team will be able to set feature goals "
                "and approve bug targeting and backporting for ANY series in "
                "ANY project in this group. You can also appoint drivers "
                "at the level of a specific project or series. So you may "
                "just want to leave this space blank, and instead let the "
                "individual projects and series have drivers."),
            required=False, vocabulary='ValidPersonOrTeam'))

    homepageurl = exported(
        URIField(
            title=_('Homepage URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'],
            allow_userinfo=False,
            description=_(
                "The project group home page. "
                "Please include the http://")),
        exported_as="homepage_url")

    wikiurl = exported(
        URIField(
            title=_('Wiki URL'),
            required=False,
            allowed_schemes=['http', 'https', 'ftp'],
            allow_userinfo=False,
            description=_("The URL of this project group's wiki, "
                          "if it has one. Please include the http://")),
        exported_as="wiki_url")

    lastdoap = TextLine(
        title=_('Last-parsed RDF fragment'),
        description=_("The last RDF fragment for this "
                      "entity that we received and parsed, or "
                      "generated."),
        required=False)

    sourceforgeproject = exported(
        TextLine(
            title=_("SourceForge Project Name"),
            description=_("The SourceForge project name for this "
                          "project group, if it is in SourceForge."),
            required=False),
        exported_as="sourceforge_project")

    freshmeatproject = exported(
        TextLine(
            title=_("Freshmeat Project Name"),
            description=_("The Freshmeat project name for this "
                          "project group, if it is in Freshmeat."),
            required=False),
        exported_as="freshmeat_project")

    homepage_content = exported(
        Text(
            title=_("Homepage Content"), required=False,
            description=_(
                "The content of this project group's home page. Edit this "
                "and it will be displayed for all the world to see. It is "
                "NOT a wiki so you cannot undo changes.")))

    icon = exported(
        IconImageUpload(
            title=_("Icon"), required=False,
            default_image_resource='/@@/project',
            description=_(
                "A small image of exactly 14x14 pixels and at most 5kb in "
                "size, that can be used to identify this project group. The "
                "icon will be displayed in Launchpad everywhere that we link "
                "to this project group. For example in listings or tables of "
                "active project groups.")))

    logo = exported(
        LogoImageUpload(
            title=_("Logo"), required=False,
            default_image_resource='/@@/project-logo',
            description=_(
                "An image of exactly 64x64 pixels that will be displayed in "
                "the heading of all pages related to this project group. It "
                "should be no bigger than 50kb in size.")))

    mugshot = exported(
        MugshotImageUpload(
            title=_("Brand"), required=False,
            default_image_resource='/@@/project-mugshot',
            description=_(
                "A large image of exactly 192x192 pixels, that will be "
                "displayed on this project group's home page in Launchpad. "
                "It should be no bigger than 100kb in size. ")))

    bugtracker = exported(
        ReferenceChoice(title=_('Bug Tracker'), required=False,
               vocabulary='BugTracker', schema=IBugTracker,
               description=_(
                "The bug tracker the projects in this project group use.")),
        exported_as="bug_tracker")

    # products.value_type will be set to IProduct once IProduct is defined.
    products = exported(
        CollectionField(
            title=_('List of active projects for this project group.'),
            value_type=Reference(Interface)),
        exported_as="projects")

    bug_reporting_guidelines = exported(
        Text(
            title=(
                u"If I\N{right single quotation mark}m reporting a bug, "
                u"I should include, if possible"),
            description=(
                u"These guidelines will be shown to "
                "anyone reporting a bug."),
            required=False,
            max_length=50000))

    bug_reported_acknowledgement = exported(
        Text(
            title=(
                u"After reporting a bug, I can expect the following."),
            description=(
                u"This message of acknowledgement will be displayed "
                "to anyone after reporting a bug."),
            required=False,
            max_length=50000))

    enable_bugfiling_duplicate_search = Bool(
        title=u"Search for possible duplicate bugs when a new bug is filed",
        required=False, readonly=True)

    def getProduct(name):
        """Get a product with name `name`."""

    def getConfigurableProducts():
        """Get all products that can be edited by user."""

    def translatables():
        """Return an iterator over products that have resources translatables.

        It also should have IProduct.official_rosetta flag set.
        """

    def has_translatable():
        """Return a boolean showing the existance of translatables products.
        """

    def has_branches():
        """Return a boolean showing the existance of products with branches.
        """

    def hasProducts():
        """Returns True if a project has products associated with it, False
        otherwise.
        """

    def getSeries(series_name):
        """Return a ProjectGroupSeries object with name `series_name`."""

    product_milestones = Attribute('all the milestones for all the products.')


class IProjectGroup(IProjectGroupPublic,
                    IProjectGroupModerate,
                    IStructuralSubscriptionTarget,
                    ITranslationPolicy):
    """A ProjectGroup."""

    export_as_webservice_entry('project_group')


# Interfaces for set

class IProjectGroupSet(Interface):
    """The collection of projects."""

    export_as_webservice_collection(IProjectGroup)

    title = Attribute('Title')

    def __iter__():
        """Return an iterator over all the projects."""

    def __getitem__(name):
        """Get a project by its name."""

    def get(projectid):
        """Get a project by its id.

        If the project can't be found a NotFoundError will be raised.
        """

    def getByName(name, ignore_inactive=False):
        """Return the project with the given name, ignoring inactive projects
        if ignore_inactive is True.

        Return the default value if there is no such project.
        """

    def new(name, displayname, title, homepageurl, summary, description,
            owner, mugshot=None, logo=None, icon=None, registrant=None):
        """Create and return a project with the given arguments.

        For a description of the parameters see `IProjectGroup`.
        """

    def count_all():
        """Return the total number of projects registered in Launchpad."""

    @collection_default_content()
    @operation_parameters(text=TextLine(title=_("Search text")))
    @operation_returns_collection_of(IProjectGroup)
    @export_read_operation()
    def search(text=None, search_products=False):
        """Search through the Registry database for projects that match the
        query terms. text is a piece of text in the title / summary /
        description fields of project (and possibly product). soyuz,
        bazaar, malone etc are hints as to whether the search should
        be limited to projects that are active in those Launchpad
        applications."""

    def forReview():
        """Return a list of ProjectGroups which need review, or which have
        products that needs review."""


class IProjectGroupSeries(IHasSpecifications, IHasAppointedDriver, IHasIcon,
                     IHasOwner):
    """Interface for ProjectGroupSeries.

    This class provides the specifications related to a "virtual project
    series", i.e., to those specifactions that are assigned to a series
    of a product which is part of this project.
    """
    name = TextLine(title=u'The name of the product series.',
                    required=True, readonly=True,
                    constraint=name_validator)

    displayname = TextLine(title=u'Alias for name.',
                           required=True, readonly=True,
                           constraint=name_validator)

    title = TextLine(title=u'The title for this project series.',
                     required=True, readonly=True)

    project = Object(schema=IProjectGroup,
                     title=u"The project this series belongs to",
                     required=True, readonly=True)