Merge lp:~wallyworld/launchpad/embargoed-sharing-policy-ui-1055617 into lp:launchpad

Proposed by Ian Booth on 2012-09-27
Status: Merged
Merged at revision: 16041
Proposed branch: lp:~wallyworld/launchpad/embargoed-sharing-policy-ui-1055617
Merge into: lp:launchpad
Diff against target: 56 lines (+16/-16)
2 files modified
lib/lp/registry/services/sharingservice.py (+13/-8)
lib/lp/registry/services/tests/test_sharingservice.py (+3/-8)
To merge this branch: bzr merge lp:~wallyworld/launchpad/embargoed-sharing-policy-ui-1055617
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code 2012-09-27 Approve on 2012-09-27
Review via email: mp+126585@code.launchpad.net

Commit Message

If branch sharing policy is embargoed, do not allow it to be changed via the ui.

Description of the Change

== Implementation ==

Tweak the sharing service getBranchSharingPolicies() method to only return embargoed if that's what the current policy is.

== Tests ==

Update test_getBranchSharingPolicies_product_with_embargoed

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/services/sharingservice.py
  lib/lp/registry/services/tests/test_sharingservice.py

To post a comment you must log in.
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/services/sharingservice.py'
2--- lib/lp/registry/services/sharingservice.py 2012-09-26 22:51:02 +0000
3+++ lib/lp/registry/services/sharingservice.py 2012-09-27 01:33:20 +0000
4@@ -426,14 +426,19 @@
5 """See `ISharingService`."""
6 # Only Products have branch sharing policies. Distributions just
7 # default to Public.
8- allowed_policies = [BranchSharingPolicy.PUBLIC]
9- # Commercial projects also allow proprietary branches.
10- if (IProduct.providedBy(pillar)
11- and pillar.has_current_commercial_subscription):
12- allowed_policies.extend([
13- BranchSharingPolicy.PUBLIC_OR_PROPRIETARY,
14- BranchSharingPolicy.PROPRIETARY_OR_PUBLIC,
15- BranchSharingPolicy.PROPRIETARY])
16+ # If the branch sharing policy is EMBARGOED_OR_PROPRIETARY, then we
17+ # do not allow any other policies.
18+ allowed_policies = []
19+ if (pillar.branch_sharing_policy !=
20+ BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY):
21+ allowed_policies = [BranchSharingPolicy.PUBLIC]
22+ # Commercial projects also allow proprietary branches.
23+ if (IProduct.providedBy(pillar)
24+ and pillar.has_current_commercial_subscription):
25+ allowed_policies.extend([
26+ BranchSharingPolicy.PUBLIC_OR_PROPRIETARY,
27+ BranchSharingPolicy.PROPRIETARY_OR_PUBLIC,
28+ BranchSharingPolicy.PROPRIETARY])
29 if (pillar.branch_sharing_policy and
30 not pillar.branch_sharing_policy in allowed_policies):
31 allowed_policies.append(pillar.branch_sharing_policy)
32
33=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
34--- lib/lp/registry/services/tests/test_sharingservice.py 2012-09-26 22:51:02 +0000
35+++ lib/lp/registry/services/tests/test_sharingservice.py 2012-09-27 01:33:20 +0000
36@@ -204,17 +204,12 @@
37 [BranchSharingPolicy.PUBLIC, BranchSharingPolicy.FORBIDDEN])
38
39 def test_getBranchSharingPolicies_product_with_embargoed(self):
40- # The sharing policies will contain the product's sharing policy even
41- # if it is not in the nominally allowed policy list.
42+ # If the current sharing policy is embargoed, that is all that is
43+ # allowed.
44 product = self.factory.makeProduct(
45 branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY)
46 self._assert_getBranchSharingPolicies(
47- product,
48- [BranchSharingPolicy.PUBLIC,
49- BranchSharingPolicy.PUBLIC_OR_PROPRIETARY,
50- BranchSharingPolicy.PROPRIETARY_OR_PUBLIC,
51- BranchSharingPolicy.PROPRIETARY,
52- BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY])
53+ product, [BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY])
54
55 def test_getBranchSharingPolicies_distro(self):
56 distro = self.factory.makeDistribution()