← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/hide-build-portlet-archive into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/hide-build-portlet-archive into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1146603 in Launchpad itself: "Hide build portlet for Archive:+index when lp.View is not held"
  https://bugs.launchpad.net/launchpad/+bug/1146603

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/hide-build-portlet-archive/+merge/151864

Hide the Latest Updates portlet on Archive:+index if View isn't held -- subscribers to the archive shouldn't be shown build information, and if the portlet tries to drill down to show failures they will get a 403.
-- 
https://code.launchpad.net/~stevenk/launchpad/hide-build-portlet-archive/+merge/151864
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/hide-build-portlet-archive into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py	2013-02-20 04:51:36 +0000
+++ lib/lp/soyuz/browser/archive.py	2013-03-06 03:08:22 +0000
@@ -927,6 +927,10 @@
             archive, description, title, hide_empty=False,
             linkify_text=linkify_text)
 
+    @property
+    def display_latest_updates(self):
+        return check_permission('launchpad.View', self.context)
+
     @cachedproperty
     def latest_updates(self):
         """Return the last five published sources for this archive."""

=== modified file 'lib/lp/soyuz/templates/archive-macros.pt'
--- lib/lp/soyuz/templates/archive-macros.pt	2012-11-01 03:41:36 +0000
+++ lib/lp/soyuz/templates/archive-macros.pt	2013-03-06 03:08:22 +0000
@@ -318,7 +318,8 @@
     Present the latest updates for a PPA in a portlet.
   </tal:comment>
 
-  <tal:latest_updates define="updates view/latest_updates">
+  <tal:latest_updates define="updates view/latest_updates"
+    tal:condition="view/display_latest_updates">
   <div id="portlet-latest-updates" class="portlet">
     <h2>Latest updates</h2>
 

=== modified file 'lib/lp/soyuz/tests/test_archive_subscriptions.py'
--- lib/lp/soyuz/tests/test_archive_subscriptions.py	2013-02-20 04:29:41 +0000
+++ lib/lp/soyuz/tests/test_archive_subscriptions.py	2013-03-06 03:08:22 +0000
@@ -6,10 +6,13 @@
 from urlparse import urljoin
 
 from zope.security.interfaces import Unauthorized
+from zope.security.proxy import removeSecurityProxy
 
+from lp.buildmaster.enums import BuildStatus
 from lp.registry.interfaces.person import PersonVisibility
 from lp.services.webapp.authorization import check_permission
 from lp.services.webapp.publisher import canonical_url
+from lp.soyuz.enums import PackagePublishingStatus
 from lp.testing import (
     BrowserTestCase,
     login_person,
@@ -136,7 +139,12 @@
         with person_logged_in(self.owner):
             self.archive = self.factory.makeArchive(
                 private=True, owner=self.private_team)
-        self.factory.makeSourcePackagePublishingHistory(archive=self.archive)
+        spph = self.factory.makeSourcePackagePublishingHistory(
+            archive=self.archive, status=PackagePublishingStatus.PUBLISHED)
+        spr = removeSecurityProxy(spph).sourcepackagerelease
+        self.factory.makeBinaryPackageBuild(
+            source_package_release=spr, archive=self.archive,
+            status=BuildStatus.FAILEDTOBUILD)
         self.subscriber = self.factory.makePerson()
 
     def test_traverse_view_private_team_archive_subscriber(self):
@@ -150,8 +158,6 @@
         browser.open(url)
         content = find_tag_by_id(browser.contents, 'document')
         self.assertIsNotNone(find_tag_by_id(content, 'ppa-install'))
-        self.assertIsNotNone(
-            find_tag_by_id(content, 'portlet-latest-updates'))
 
     def test_unauthorized_subscriber_for_plus_packages(self):
         with person_logged_in(self.owner):