← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~adeuring/launchpad/bug-1071589 into lp:launchpad

 

Abel Deuring has proposed merging lp:~adeuring/launchpad/bug-1071589 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~adeuring/launchpad/bug-1071589/+merge/137659

This branch fixes bug 1071589: +sharing "Who it's shared with" section inaccurate on pure Proprietary projects

The fix is simple: The text shown below "Who it's shared with" is now different for private products.

Getting the "condition variable" info_type is a bit cumbersome because IDistribution and IProjectGroup do not define the attribute information_type, wo we must also check the piller type.

test: ./bin/test registry -vvt test_who_its_shared_with

no lint
-- 
https://code.launchpad.net/~adeuring/launchpad/bug-1071589/+merge/137659
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/launchpad/bug-1071589 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/tests/test_pillar_sharing.py'
--- lib/lp/registry/browser/tests/test_pillar_sharing.py	2012-12-02 14:48:02 +0000
+++ lib/lp/registry/browser/tests/test_pillar_sharing.py	2012-12-03 18:49:25 +0000
@@ -161,7 +161,8 @@
             pillarperson.pillar.name, pillarperson.person.name)
         browser = self.getUserBrowser(user=self.owner, url=url)
         self.assertIn(
-            'There are no shared bugs, branches, or blueprints.', browser.contents)
+            'There are no shared bugs, branches, or blueprints.',
+            browser.contents)
 
     def test_init_works(self):
         # The view works with a feature flag.
@@ -334,6 +335,30 @@
             ['Private Security', 'Private'],
             cache.objects.get('invisible_information_types'))
 
+    def run_sharing_message_test(self, pillar, owner, public):
+        with person_logged_in(owner):
+            public_pillar_sharing_info = (
+                "Everyone can see %s's public information."
+                % pillar.displayname)
+            url = canonical_url(pillar, view_name='+sharing')
+        browser = setupBrowserForUser(user=owner)
+        browser.open(url)
+        if public:
+            self.assertTrue(public_pillar_sharing_info in browser.contents)
+            self.assertFalse(
+                "This project has no public information." in browser.contents)
+        else:
+            self.assertFalse(public_pillar_sharing_info in browser.contents)
+            self.assertTrue(
+                "This project has no public information." in browser.contents)
+
+    def test_who_its_shared_with__public_pillar(self):
+        # For public projects and distributions, the sharing page
+        # shows the message "Everyone can see project's public
+        # information".
+        self.run_sharing_message_test(
+            self.pillar, self.pillar.owner, public=True)
+
 
 class TestProductSharingView(PillarSharingViewTestMixin,
                                  SharingBaseTestCase):
@@ -374,6 +399,12 @@
         self.assertIsNotNone(commercial_text)
         self.assertIsNone(non_commercial_text)
 
+    def test_who_its_shared_with__proprietary_product(self):
+        owner = self.factory.makePerson()
+        product = self.factory.makeProduct(
+            owner=owner, information_type=InformationType.PROPRIETARY)
+        self.run_sharing_message_test(product, owner, public=False)
+
 
 class TestDistributionSharingView(PillarSharingViewTestMixin,
                                       SharingBaseTestCase):

=== modified file 'lib/lp/registry/templates/pillar-sharing.pt'
--- lib/lp/registry/templates/pillar-sharing.pt	2012-11-21 19:38:47 +0000
+++ lib/lp/registry/templates/pillar-sharing.pt	2012-12-03 18:49:25 +0000
@@ -95,10 +95,17 @@
 
       </table>
     <h2>Who it's shared with</h2>
-    <div id="sharing-header">
-      <p tal:content="string:
+    <div id="sharing-header"
+         tal:define="info_type
+             python: 'Public' if context.pillar_category != 'Project' else
+                 context.information_type.title">
+      <p tal:condition="python: info_type == 'Public'"
+         tal:content="string:
         Everyone can see ${context/displayname}'s public information. You can
-        choose who can see the private bugs and branches.">
+        choose who can see the private bugs, branches and blueprints.">
+     </p>
+     <p tal:condition="python: info_type != 'Public'"
+       tal:content="string: This project has no public information.">
      </p>
     </div>
     <ul class="horizontal">


Follow ups