← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/bug-subscription-link into lp:launchpad

 

Benji York has proposed merging lp:~benji/launchpad/bug-subscription-link into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-subscription-link/+merge/56422

This branch adds a link to a list of the user's bug subscriptions to the
subscriptions portlet.  Visibility of the link is predicated on the same
feature flag as the rest of the new structural subscription story.

Tests
=====

Tests were added to lib/lp/bugs/browser/tests/test_bug_views.py.


Lint
====

"make lint" died with an ImportError.

-- 
https://code.launchpad.net/~benji/launchpad/bug-subscription-link/+merge/56422
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-subscription-link into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bug.py'
--- lib/lp/bugs/browser/bug.py	2011-03-30 11:29:44 +0000
+++ lib/lp/bugs/browser/bug.py	2011-04-05 18:07:31 +0000
@@ -199,8 +199,8 @@
     usedfor = IBug
     links = [
         'editdescription', 'markduplicate', 'visibility', 'addupstream',
-        'adddistro', 'subscription', 'addsubscriber', 'addcomment',
-        'nominate', 'addbranch', 'linktocve', 'unlinkcve',
+        'adddistro', 'subscription', 'addsubscriber', 'editsubscriptions',
+        'addcomment', 'nominate', 'addbranch', 'linktocve', 'unlinkcve',
         'createquestion', 'mute_subscription', 'removequestion',
         'activitylog', 'affectsmetoo']
 
@@ -273,6 +273,13 @@
                 'Launchpad will email that person whenever this bugs '
                 'changes'))
 
+    def editsubscriptions(self):
+        """Return the 'Edit subscriptions' Link."""
+        text = 'Edit subscriptions'
+        return Link(
+            '+subscriptions', text, icon='edit', summary=(
+                'View and change your subscriptions to this bug'))
+
     def mute_subscription(self):
         """Return the 'Mute subscription' Link."""
         user = getUtility(ILaunchBag).user

=== modified file 'lib/lp/bugs/browser/tests/test_bug_views.py'
--- lib/lp/bugs/browser/tests/test_bug_views.py	2011-03-30 11:04:40 +0000
+++ lib/lp/bugs/browser/tests/test_bug_views.py	2011-04-05 18:07:31 +0000
@@ -8,8 +8,11 @@
 from zope.component import getUtility
 
 from canonical.launchpad.webapp.interfaces import IOpenLaunchBag
+from canonical.launchpad.webapp.servers import LaunchpadTestRequest
 from canonical.testing.layers import DatabaseFunctionalLayer
 
+from lp.services.features.testing import FeatureFixture
+from lp.services.features import get_relevant_feature_controller
 from lp.testing import (
     feature_flags,
     person_logged_in,
@@ -32,8 +35,6 @@
         launchbag = getUtility(IOpenLaunchBag)
         launchbag.add(self.bug)
         launchbag.add(self.bug.default_bugtask)
-        with feature_flags():
-            set_feature_flag(u'malone.advanced-subscriptions.enabled', u'on')
 
     def test_mute_subscription_link_not_shown_for_non_subscribers(self):
         # If a person is not already subscribed to a bug in some way,
@@ -54,3 +55,21 @@
                 # whether or not to display the mute link.
                 html = view.render()
                 self.assertFalse('mute_subscription' in html)
+
+    def test_edit_subscriptions_link_shown_when_feature_enabled(self):
+        flag = 'malone.advanced-structural-subscriptions.enabled'
+        with FeatureFixture({flag: 'on'}):
+            request = LaunchpadTestRequest()
+            request.features = get_relevant_feature_controller()
+            view = create_initialized_view(
+                self.bug, name="+portlet-subscribers", request=request)
+            html = view.render()
+        self.assertTrue('menu-link-editsubscriptions' in html)
+        self.assertTrue('/+subscriptions' in html)
+
+    def test_edit_subscriptions_link_not_shown_when_feature_disabled(self):
+        view = create_initialized_view(
+            self.bug, name="+portlet-subscribers")
+        html = view.render()
+        self.assertTrue('menu-link-editsubscriptions' not in html)
+        self.assertTrue('/+subscriptions' not in html)

=== modified file 'lib/lp/bugs/templates/bug-portlet-subscribers.pt'
--- lib/lp/bugs/templates/bug-portlet-subscribers.pt	2011-03-30 11:04:40 +0000
+++ lib/lp/bugs/templates/bug-portlet-subscribers.pt	2011-04-05 18:07:31 +0000
@@ -13,6 +13,8 @@
       tal:content="structure context_menu/subscription/render" />
     <div id="sub-unsub-spinner">Subscribing...</div>
     <div tal:content="structure context_menu/addsubscriber/render" />
+    <div tal:condition="request/features/malone.advanced-structural-subscriptions.enabled"
+        tal:content="structure context_menu/editsubscriptions/render" />
     <tal:show-mute condition="view/user_should_see_mute_link">
       <div
         tal:attributes="class view/current_user_mute_class"