← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~julian-edwards/launchpad/ppa-packages-page-bug-660065 into lp:launchpad

 

Julian Edwards has proposed merging lp:~julian-edwards/launchpad/ppa-packages-page-bug-660065 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #660065 commercial admins can't see private PPA +packages pages
  https://bugs.launchpad.net/bugs/660065


Make sure that commercial admins can see Archive:+packages
-- 
https://code.launchpad.net/~julian-edwards/launchpad/ppa-packages-page-bug-660065/+merge/42843
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/ppa-packages-page-bug-660065 into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py	2010-11-23 23:22:27 +0000
+++ lib/lp/soyuz/browser/archive.py	2010-12-06 15:40:01 +0000
@@ -478,10 +478,13 @@
     def packages(self):
         text = 'View package details'
         link = Link('+packages', text, icon='info')
-        # Disable the link for P3As if they don't have upload rights.
+        # Disable the link for P3As if they don't have upload rights,
+        # except if the user is a commercial admin.
         if self.context.private:
             if not check_permission('launchpad.Append', self.context):
-                link.enabled = False
+                admins = getUtility(ILaunchpadCelebrities).commercial_admin
+                if not self.user.inTeam(admins):
+                    link.enabled = False
         return link
 
     @enabled_with_permission('launchpad.Edit')
@@ -1023,8 +1026,12 @@
     def initialize(self):
         super(ArchivePackagesView, self).initialize()
         if self.context.private:
+            # To see the +packages page, you must be an uploader, or a
+            # commercial admin.
             if not check_permission('launchpad.Append', self.context):
-                raise Unauthorized
+                admins = getUtility(ILaunchpadCelebrities).commercial_admin
+                if not self.user.inTeam(admins):
+                    raise Unauthorized
 
     @property
     def page_title(self):

=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py	2010-11-10 05:53:57 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py	2010-12-06 15:40:01 +0000
@@ -11,6 +11,8 @@
     'TestPPAPackages',
     ]
 
+from zope.component import getUtility
+
 from testtools.matchers import (
     Equals,
     LessThan,
@@ -20,6 +22,7 @@
 
 from canonical.launchpad.webapp import canonical_url
 from canonical.testing.layers import LaunchpadFunctionalLayer
+from canonical.launchpad.utilities.celebrities import ILaunchpadCelebrities
 from lp.soyuz.browser.archive import ArchiveNavigationMenu
 from lp.testing import (
     login,
@@ -67,6 +70,17 @@
             Unauthorized, create_initialized_view, self.private_ppa,
             "+packages")
 
+    def test_packages_authorized_for_commercial_admin_with_subscription(self):
+        # A commercial admin should always be able to see +packages even
+        # if they have a subscription.
+        login('admin@xxxxxxxxxxxxx')
+        admins = getUtility(ILaunchpadCelebrities).commercial_admin
+        admins.addMember(self.joe, admins)
+        login_person(self.joe)
+        view = create_initialized_view(self.private_ppa, "+packages")
+        menu = ArchiveNavigationMenu(view)
+        self.assertTrue(menu.packages().enabled)
+
     def test_packages_authorized(self):
         """A person with launchpad.{Append,Edit} will be able to do so"""
         login_person(self.private_ppa.owner)