← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/info-type-adds-policy into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/info-type-adds-policy into lp:launchpad.

Commit message:
Product information_type access policy is retained.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1074139 in Launchpad itself: "Setting policies different from project information_type locks the owner out."
  https://bugs.launchpad.net/launchpad/+bug/1074139

For more details, see:
https://code.launchpad.net/~abentley/launchpad/info-type-adds-policy/+merge/132749

= Summary =
Fix bug #1074139: Setting policies different from project information_type locks the owner out

== Proposed fix ==
Update Product._pruneUnusedPolicies to consider Product.information_type when determining which policies can be deleted.

== Pre-implementation notes ==
None

== LOC Rationale ==
Part of private products.

== Implementation details ==
Cleaned up some lint as a driveby.

== Tests ==
bin/test -t test_information_type_prevents_pruning product

== Demo and Q/A ==
Create a Proprietary product.  Change all the sharing policies to Public.  You should still be able to see the product, and you should be listed under Proprietary.


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/model/product.py
  lib/lp/registry/tests/test_product.py
-- 
https://code.launchpad.net/~abentley/launchpad/info-type-adds-policy/+merge/132749
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/info-type-adds-policy into lp:launchpad.
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2012-10-26 17:58:33 +0000
+++ lib/lp/registry/model/product.py	2012-11-02 20:16:25 +0000
@@ -704,6 +704,7 @@
         )
         allowed_types = allowed_bug_types.union(allowed_branch_types)
         allowed_types = allowed_types.union(allowed_specification_types)
+        allowed_types.add(self.information_type)
         # Fetch all APs, and after filtering out ones that are forbidden
         # by the bug, branch, and specification policies, the APs that have no
         # APAs are unused and can be deleted.

=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py	2012-10-26 17:58:33 +0000
+++ lib/lp/registry/tests/test_product.py	2012-11-02 20:16:25 +0000
@@ -909,6 +909,21 @@
                 self.assertTrue(check_permission('launchpad.View', product))
             self.assertFalse(check_permission('launchpad.View', product))
 
+    def test_information_type_prevents_pruning(self):
+        # Access policies for Product.information_type are not pruned.
+        owner = self.factory.makePerson()
+        for info_type in [
+            InformationType.PROPRIETARY, InformationType.EMBARGOED]:
+            product = self.factory.makeProduct(
+                information_type=info_type, owner=owner)
+            with person_logged_in(owner):
+                product.setBugSharingPolicy(BugSharingPolicy.PUBLIC)
+                product.setSpecificationSharingPolicy(
+                    SpecificationSharingPolicy.PUBLIC)
+                product.setBranchSharingPolicy(BranchSharingPolicy.PUBLIC)
+            self.assertIsNot(None, getUtility(IAccessPolicySource).find(
+                [(product, info_type)]).one())
+
 
 class TestProductBugInformationTypes(TestCaseWithFactory):
 
@@ -1877,7 +1892,7 @@
     def test_users_private_products(self):
         # Ignore any public products the user may own.
         owner = self.factory.makePerson()
-        public = self.factory.makeProduct(
+        self.factory.makeProduct(
             information_type=InformationType.PUBLIC,
             owner=owner)
         proprietary = self.factory.makeProduct(
@@ -1990,9 +2005,9 @@
         product = self.factory.makeProduct(
             owner=owner, translations_usage=ServiceUsage.LAUNCHPAD)
         series = self.factory.makeProductSeries(product)
-        po_template = self.factory.makePOTemplate(productseries=series)
+        self.factory.makePOTemplate(productseries=series)
         with person_logged_in(owner):
-            product.information_type=InformationType.PROPRIETARY
+            product.information_type = InformationType.PROPRIETARY
         # Anonymous users do not see private products.
         with person_logged_in(ANONYMOUS):
             translatables = getUtility(IProductSet).getTranslatables()


Follow ups