← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/person-branches-menu-snaps into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/person-branches-menu-snaps into lp:launchpad.

Commit message:
Add a "Snap packages" link to Person:+branches.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/person-branches-menu-snaps/+merge/272151

Add a "Snap packages" link to Person:+branches, to go with the existing "Source package recipes" link.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/person-branches-menu-snaps into lp:launchpad.
=== modified file 'lib/lp/code/browser/branchlisting.py'
--- lib/lp/code/browser/branchlisting.py	2015-07-09 20:06:17 +0000
+++ lib/lp/code/browser/branchlisting.py	2015-09-23 17:56:26 +0000
@@ -108,6 +108,7 @@
 from lp.registry.model.sourcepackage import SourcePackage
 from lp.services.browser_helpers import get_plural_text
 from lp.services.config import config
+from lp.services.features import getFeatureFlag
 from lp.services.feeds.browser import (
     FeedsMixin,
     PersonBranchesFeedLink,
@@ -129,6 +130,7 @@
     )
 from lp.services.webapp.batching import TableBatchNavigator
 from lp.services.webapp.publisher import LaunchpadView
+from lp.snappy.interfaces.snap import SNAP_FEATURE_FLAG
 
 
 class BranchBadges(HasBadgeBase):
@@ -867,7 +869,7 @@
 
     usedfor = IPerson
     facet = 'branches'
-    links = ['branches', 'active_reviews', 'source_package_recipes']
+    links = ['branches', 'active_reviews', 'source_package_recipes', 'snaps']
 
     @property
     def person(self):
@@ -890,11 +892,17 @@
             '+recipes', 'Source package recipes',
             enabled=IPerson.providedBy(self.context))
 
+    def snaps(self):
+        enabled = (
+            bool(getFeatureFlag(SNAP_FEATURE_FLAG)) and
+            IPerson.providedBy(self.context))
+        return Link('+snaps', 'Snap packages', enabled=enabled)
+
 
 class PersonProductBranchesMenu(PersonBranchesMenu):
 
     usedfor = IPersonProduct
-    links = ['branches', 'active_reviews', 'source_package_recipes']
+    links = ['branches', 'active_reviews', 'source_package_recipes', 'snaps']
 
     @property
     def person(self):

=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
--- lib/lp/code/browser/tests/test_branchlisting.py	2015-06-15 08:35:10 +0000
+++ lib/lp/code/browser/tests/test_branchlisting.py	2015-09-23 17:56:26 +0000
@@ -44,12 +44,15 @@
 from lp.services.features.testing import FeatureFixture
 from lp.services.webapp import canonical_url
 from lp.services.webapp.servers import LaunchpadTestRequest
+from lp.snappy.interfaces.snap import SNAP_FEATURE_FLAG
 from lp.testing import (
     admin_logged_in,
     BrowserTestCase,
+    feature_flags,
     login_person,
     normalize_whitespace,
     person_logged_in,
+    set_feature_flag,
     TestCase,
     TestCaseWithFactory,
     time_counter,
@@ -382,6 +385,23 @@
         else:
             self.assertThat(page, Not(recipes_matcher))
 
+    def test_branch_list_snaps_link(self):
+        # The link to the snap packages is displayed if the appropriate
+        # feature flag is set.
+        snaps_matcher = soupmatchers.HTMLContains(
+            soupmatchers.Tag(
+                'Snap packages link', 'a', text='Snap packages',
+                attrs={'href': self.base_url + '/+snaps'}))
+        page = self.get_branch_list_page()
+        self.assertThat(page, Not(snaps_matcher))
+        with feature_flags():
+            set_feature_flag(SNAP_FEATURE_FLAG, u'on')
+            page = self.get_branch_list_page()
+            if IPerson.providedBy(self.default_target):
+                self.assertThat(page, snaps_matcher)
+            else:
+                self.assertThat(page, Not(snaps_matcher))
+
 
 class TestSimplifiedPersonProductBranchesView(
     TestSimplifiedPersonBranchesView):

=== modified file 'lib/lp/code/templates/person-codesummary.pt'
--- lib/lp/code/templates/person-codesummary.pt	2015-04-19 12:56:32 +0000
+++ lib/lp/code/templates/person-codesummary.pt	2015-09-23 17:56:26 +0000
@@ -17,5 +17,8 @@
     <tr class="code-links" tal:condition="menu/source_package_recipes/enabled">
       <td tal:content="structure menu/source_package_recipes/render" />
     </tr>
+    <tr class="code-links" tal:condition="menu/snaps/enabled">
+      <td tal:content="structure menu/snaps/render" />
+    </tr>
   </table>
 </div>


Follow ups