← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/deal-with-changeinformationtype into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/deal-with-changeinformationtype into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1006081 in Launchpad itself: "BranchCannotChangeInformationType trying to make a branch public"
  https://bugs.launchpad.net/launchpad/+bug/1006081

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/deal-with-changeinformationtype/+merge/108284

When information_type handling for Branch was added, some of the rules changed in terms when a branch can change privacy. Since branches stacked on private branches are no longer allowed to change their privacy, we should detect that case properly instead of pretending to allow it and then de-praming our toys in the form of an OOPS.
-- 
https://code.launchpad.net/~stevenk/launchpad/deal-with-changeinformationtype/+merge/108284
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/deal-with-changeinformationtype into lp:launchpad.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2012-05-30 05:04:40 +0000
+++ lib/lp/code/browser/branch.py	2012-06-01 05:12:19 +0000
@@ -122,6 +122,7 @@
 from lp.code.interfaces.branchmergeproposal import IBranchMergeProposal
 from lp.code.interfaces.branchnamespace import IBranchNamespacePolicy
 from lp.code.interfaces.codereviewvote import ICodeReviewVoteReference
+from lp.registry.enums import PRIVATE_INFORMATION_TYPES
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.productseries import IProductSeries
 from lp.registry.vocabularies import (
@@ -1069,7 +1070,8 @@
 
             # If this branch is public but is deemed private because it is
             # stacked on a private branch, disable the field.
-            if not branch.explicitly_private:
+            if (branch.stacked_on and branch.stacked_on.information_type in
+                PRIVATE_INFORMATION_TYPES):
                 show_private_field = False
                 private_info = Bool(
                     __name__="private",

=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py	2012-05-30 03:27:20 +0000
+++ lib/lp/code/browser/tests/test_branch.py	2012-06-01 05:12:19 +0000
@@ -933,6 +933,21 @@
                 canonical_url(branch) + '/+edit', user=admin)
             self.assertRaises(LookupError, browser.getControl, "Proprietary")
 
+    def test_can_not_change_privacy_of_stacked_on_private(self):
+        # The privacy field is not shown if the branch is stacked on a 
+        # private branch.
+        owner = self.factory.makePerson()
+        product = self.factory.makeProduct(owner=owner)
+        stacked_on = self.factory.makeBranch(
+            product=product, owner=owner,
+            information_type=InformationType.USERDATA)
+        branch = self.factory.makeBranch(
+            product=product, owner=owner, stacked_on=stacked_on)
+        with person_logged_in(owner):
+            browser = self.getUserBrowser(
+                canonical_url(branch) + '/+edit', user=owner)
+        self.assertRaises(
+            LookupError, browser.getControl, "Keep branch confidential")
 
 class TestBranchUpgradeView(TestCaseWithFactory):
 


Follow ups