~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/blueprints/interfaces/specificationbranch.py

[r=sinzui][bug=855670] Add additional checks to the private team
        launchpad.LimitedView security adaptor so more users in defined
        roles can see the team.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
# pylint: disable-msg=E0211,E0213
 
5
 
 
6
"""Interfaces for linking Specifications and Branches."""
 
7
 
 
8
__metaclass__ = type
 
9
 
 
10
__all__ = [
 
11
    "ISpecificationBranch",
 
12
    "ISpecificationBranchSet",
 
13
    ]
 
14
 
 
15
from lazr.restful.declarations import (
 
16
    export_as_webservice_entry,
 
17
    export_operation_as,
 
18
    export_write_operation,
 
19
    exported,
 
20
    operation_for_version,
 
21
    )
 
22
from lazr.restful.fields import (
 
23
    Reference,
 
24
    ReferenceChoice,
 
25
    )
 
26
from zope.interface import Interface
 
27
from zope.schema import Int
 
28
 
 
29
from canonical.launchpad import _
 
30
from lp.app.interfaces.launchpad import IHasDateCreated
 
31
from lp.blueprints.interfaces.specification import ISpecification
 
32
from lp.code.interfaces.branch import IBranch
 
33
from lp.registry.interfaces.person import IPerson
 
34
 
 
35
 
 
36
class ISpecificationBranch(IHasDateCreated):
 
37
    """A branch linked to a specification."""
 
38
 
 
39
    export_as_webservice_entry(as_of="beta")
 
40
 
 
41
    id = Int(title=_("Specification Branch #"))
 
42
    specification = exported(
 
43
        ReferenceChoice(
 
44
            title=_("Blueprint"), vocabulary="Specification",
 
45
            required=True,
 
46
            readonly=True, schema=ISpecification), as_of="beta")
 
47
    branch = exported(
 
48
        ReferenceChoice(
 
49
            title=_("Branch"),
 
50
            vocabulary="Branch",
 
51
            required=True,
 
52
            schema=IBranch), as_of="beta")
 
53
 
 
54
    registrant = exported(
 
55
        Reference(
 
56
            schema=IPerson, readonly=True, required=True,
 
57
            title=_("The person who linked the bug to the branch")),
 
58
        as_of="beta")
 
59
 
 
60
    @export_operation_as('delete')
 
61
    @export_write_operation()
 
62
    @operation_for_version('beta')
 
63
    def destroySelf():
 
64
        """Destroy this specification branch link"""
 
65
 
 
66
 
 
67
class ISpecificationBranchSet(Interface):
 
68
    """Methods that work on the set of all specification branch links."""
 
69
 
 
70
    def getSpecificationBranchesForBranches(branches, user):
 
71
        """Return a sequence of ISpecificationBranch instances associated with
 
72
        the given branches.
 
73
 
 
74
        Only return instances that are visible to the user.
 
75
        """