Merge lp:~deryck/launchpad/specification-sharing-policy-unused into lp:launchpad

Proposed by Deryck Hodge on 2012-09-12
Status: Merged
Approved by: Aaron Bentley on 2012-09-12
Approved revision: no longer in the source branch.
Merged at revision: 15964
Proposed branch: lp:~deryck/launchpad/specification-sharing-policy-unused
Merge into: lp:launchpad
Diff against target: 182 lines (+83/-0)
4 files modified
lib/lp/blueprints/model/specification.py (+14/-0)
lib/lp/registry/enums.py (+39/-0)
lib/lp/registry/interfaces/product.py (+18/-0)
lib/lp/registry/model/product.py (+12/-0)
To merge this branch: bzr merge lp:~deryck/launchpad/specification-sharing-policy-unused
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2012-09-12 Approve on 2012-09-12
Review via email: mp+124021@code.launchpad.net

Commit Message

Add SpecificationSharingPolicy to Product, as a first step toward getting sharing policy enabled for blueprints.

Description of the Change

This branch adds specification_sharing_policy to Product. It's a first branch toward configuring sharing policy for blueprints. I'll admit my own TDD sins here and say that this is untested code, but I started this branch, trying to sort out how this all fit together. So this branch remains just the start of the sharing policy for blueprints. I will have separate branches for review to add a garbo job for populating specification_sharing_policy for existing projects and another that adds Product.getAllowedSpecificationInformationTypes and Production.getDefaultSpecificationInformationType. This last branch is where tests will live, to ensure the two methods that use SpecificationSharingPolicy return the correct information types.

There is no qa since this is unused code.

The branch is justified in terms of LOC because it's part of the disclosure project.

To post a comment you must log in.
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/blueprints/model/specification.py'
2--- lib/lp/blueprints/model/specification.py 2012-09-12 19:40:39 +0000
3+++ lib/lp/blueprints/model/specification.py 2012-09-13 10:36:19 +0000
4@@ -9,6 +9,7 @@
5 'recursive_blocked_query',
6 'recursive_dependent_query',
7 'Specification',
8+ 'SPECIFICATION_POLICY_ALLOWED_TYPES',
9 'SpecificationSet',
10 ]
11
12@@ -77,6 +78,7 @@
13 InformationType,
14 PRIVATE_INFORMATION_TYPES,
15 PUBLIC_INFORMATION_TYPES,
16+ SpecificationSharingPolicy,
17 )
18 from lp.registry.errors import CannotChangeInformationType
19 from lp.registry.interfaces.distribution import IDistribution
20@@ -127,6 +129,18 @@
21 )""" % spec.id
22
23
24+SPECIFICATION_POLICY_ALLOWED_TYPES = {
25+ SpecificationSharingPolicy.PUBLIC: [InformationType.PUBLIC],
26+ SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY:
27+ [InformationType.PUBLIC, InformationType.PROPRIETARY],
28+ SpecificationSharingPolicy.PROPRIETARY_OR_PUBLIC:
29+ [InformationType.PUBLIC, InformationType.PROPRIETARY],
30+ SpecificationSharingPolicy.PROPRIETARY: [InformationType.PROPRIETARY],
31+ SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY:
32+ [InformationType.PROPRIETARY, InformationType.EMBARGOED],
33+ }
34+
35+
36 class Specification(SQLBase, BugLinkTargetMixin):
37 """See ISpecification."""
38
39
40=== modified file 'lib/lp/registry/enums.py'
41--- lib/lp/registry/enums.py 2012-09-06 19:05:05 +0000
42+++ lib/lp/registry/enums.py 2012-09-13 10:36:19 +0000
43@@ -24,6 +24,7 @@
44 'ProductJobType',
45 'SECURITY_INFORMATION_TYPES',
46 'SharingPermission',
47+ 'SpecificationSharingPolicy',
48 'TeamMembershipPolicy',
49 'TeamMembershipRenewalPolicy',
50 ]
51@@ -200,6 +201,44 @@
52 """)
53
54
55+class SpecificationSharingPolicy(DBEnumeratedType):
56+
57+ PUBLIC = DBItem(1, """
58+ Public
59+
60+ Specifications are public.
61+ """)
62+
63+ PUBLIC_OR_PROPRIETARY = DBItem(2, """
64+ Public, can be proprietary
65+
66+ New specifications are public, but can be made proprietary later.
67+ """)
68+
69+ PROPRIETARY_OR_PUBLIC = DBItem(3, """
70+ Proprietary, can be public
71+
72+ New specifications are proprietary, but can be made public later. Only
73+ people who can see the project's proprietary information can create
74+ new specifications.
75+ """)
76+
77+ PROPRIETARY = DBItem(4, """
78+ Proprietary
79+
80+ Specifications are always proprietary. Only people who can see the
81+ project's proprietary information can create new specifications.
82+ """)
83+
84+ EMBARGOED_OR_PROPRIETARY = DBItem(5, """
85+ Embargoed, can be proprietary
86+
87+ New specifications are embargoed, but can be made proprietary later.
88+ Only people who can see the project's proprietary information can
89+ create new specifications.
90+ """)
91+
92+
93 class TeamMembershipRenewalPolicy(DBEnumeratedType):
94 """TeamMembership Renewal Policy.
95
96
97=== modified file 'lib/lp/registry/interfaces/product.py'
98--- lib/lp/registry/interfaces/product.py 2012-09-10 13:24:03 +0000
99+++ lib/lp/registry/interfaces/product.py 2012-09-13 10:36:19 +0000
100@@ -108,6 +108,7 @@
101 from lp.registry.enums import (
102 BranchSharingPolicy,
103 BugSharingPolicy,
104+ SpecificationSharingPolicy,
105 InformationType,
106 )
107 from lp.registry.interfaces.announcement import IMakesAnnouncements
108@@ -648,6 +649,11 @@
109 description=_("Sharing policy for this project's bugs."),
110 required=False, readonly=True, vocabulary=BugSharingPolicy),
111 as_of='devel')
112+ specification_sharing_policy = exported(Choice(
113+ title=_('Specification sharing policy'),
114+ description=_("Sharing policy for this project's specifications."),
115+ required=False, readonly=True, vocabulary=SpecificationSharingPolicy),
116+ as_of='devel')
117
118 licenses = exported(
119 Set(title=_('Licences'),
120@@ -906,6 +912,18 @@
121 Checks authorization and entitlement.
122 """
123
124+ @mutator_for(IProductPublic['specification_sharing_policy'])
125+ @operation_parameters(
126+ specification_sharing_policy=copy_field(
127+ IProductPublic['specification_sharing_policy']))
128+ @export_write_operation()
129+ @operation_for_version("devel")
130+ def setSpecificationSharingPolicy(specification_sharing_policy):
131+ """Mutator for specification_sharing_policy.
132+
133+ Checks authorization and entitlement.
134+ """
135+
136
137 class IProduct(
138 IHasBugSupervisor, IProductEditRestricted,
139
140=== modified file 'lib/lp/registry/model/product.py'
141--- lib/lp/registry/model/product.py 2012-09-12 19:40:39 +0000
142+++ lib/lp/registry/model/product.py 2012-09-13 10:36:19 +0000
143@@ -86,6 +86,7 @@
144 from lp.blueprints.model.specification import (
145 HasSpecificationsMixin,
146 Specification,
147+ SPECIFICATION_POLICY_ALLOWED_TYPES,
148 )
149 from lp.blueprints.model.sprint import HasSprintsMixin
150 from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
151@@ -122,6 +123,7 @@
152 FREE_INFORMATION_TYPES,
153 InformationType,
154 PRIVATE_INFORMATION_TYPES,
155+ SpecificationSharingPolicy,
156 PUBLIC_PROPRIETARY_INFORMATION_TYPES,
157 )
158 from lp.registry.errors import CommercialSubscribersOnly
159@@ -487,6 +489,8 @@
160 enum=BugSharingPolicy, notNull=False, default=None)
161 branch_sharing_policy = EnumCol(
162 enum=BranchSharingPolicy, notNull=False, default=None)
163+ specification_sharing_policy = EnumCol(
164+ enum=SpecificationSharingPolicy, notNull=False, default=None)
165 autoupdate = BoolCol(dbName='autoupdate', notNull=True, default=False)
166 freshmeatproject = StringCol(notNull=False, default=None)
167 sourceforgeproject = StringCol(notNull=False, default=None)
168@@ -600,6 +604,14 @@
169 self.bug_sharing_policy = bug_sharing_policy
170 self._pruneUnusedPolicies()
171
172+ def setSpecificationSharingPolicy(self, specification_sharing_policy):
173+ """See `IProductEditRestricted`."""
174+ self._prepare_to_set_sharing_policy(
175+ specification_sharing_policy, SpecificationSharingPolicy,
176+ 'specifications', SPECIFICATION_POLICY_ALLOWED_TYPES)
177+ self.specification_sharing_policy = specification_sharing_policy
178+ self._pruneUnusedPolicies()
179+
180 def getAllowedBugInformationTypes(self):
181 """See `IProduct.`"""
182 if self.bug_sharing_policy is not None: