Merge lp:~bac/launchpad/nix-subscriber-list into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 12904
Proposed branch: lp:~bac/launchpad/nix-subscriber-list
Merge into: lp:launchpad
Diff against target: 317 lines (+74/-39)
3 files modified
lib/lp/bugs/browser/bug.py (+1/-1)
lib/lp/bugs/browser/tests/test_bugsubscription_views.py (+60/-27)
lib/lp/bugs/templates/bug-portlet-subscribers-content.pt (+13/-11)
To merge this branch: bzr merge lp:~bac/launchpad/nix-subscriber-list
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+58723@code.launchpad.net

Commit message

[r=gary][bug=768483] Do not show 'Also notified' in the bug subscriber portlet when advanced subscriptions are used.

Description of the change

= Summary =

With advanced bug subscriptions it is unclear whether a person will be
notified for any given change to a bug. Because of this new granularity
of notification, the list of subscribed people shown under 'Also
notified' is misleading. We feel the list is now of diminished
usefulness and are removing it.

== Proposed fix ==

Use a feature flag currently tied to the malone-alpha team to suppress
the generation of that portion of the portlet.

== Pre-implementation notes ==

Chat with Gary and Benji.

== Implementation details ==

Some changes were made to other parts of the test for clarity regarding
the use of feature flags.

== Tests ==

bin/test -vvm lp.bugs -t test_bugscription_views

== Demo and Q/A ==

= Launchpad lint =

I'll fix the lint.

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/templates/bug-portlet-subscribers-content.pt
  lib/lp/bugs/browser/bug.py
  lib/lp/bugs/browser/tests/test_bugsubscription_views.py

./lib/lp/bugs/browser/tests/test_bugsubscription_views.py
     190: local variable 'level' is assigned to but never used
     210: local variable 'level' is assigned to but never used
     235: local variable 'level' is assigned to but never used
     269: local variable 'subscription' is assigned to but never used
     340: local variable 'subscribe_view' is assigned to but never used
     361: local variable 'subscribe_view' is assigned to but never used
     450: local variable 'sub' is assigned to but never used
     500: local variable 'mute_view' is assigned to but never used

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Great, thank you Brad!

Per our discussion on IRC:

 - We agreed that the comment on line 206 is wrong ("# Subscribe someone to the target.") Please move or delete it.

 - Calculating also notified subscribers can be expensive; if we don't render it, let's not calculate it.

Gary

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bug.py'
2--- lib/lp/bugs/browser/bug.py 2011-04-05 17:55:44 +0000
3+++ lib/lp/bugs/browser/bug.py 2011-04-21 18:31:32 +0000
4@@ -275,7 +275,7 @@
5
6 def editsubscriptions(self):
7 """Return the 'Edit subscriptions' Link."""
8- text = 'Edit subscriptions'
9+ text = 'Edit all of your subscriptions'
10 return Link(
11 '+subscriptions', text, icon='edit', summary=(
12 'View and change your subscriptions to this bug'))
13
14=== modified file 'lib/lp/bugs/browser/tests/test_bugsubscription_views.py'
15--- lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-04-15 11:02:24 +0000
16+++ lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-04-21 18:31:32 +0000
17@@ -15,26 +15,28 @@
18 BugSubscriptionSubscribeSelfView,
19 )
20 from lp.bugs.enum import BugNotificationLevel
21+from lp.services.features.testing import FeatureFixture
22 from lp.testing import (
23- feature_flags,
24 person_logged_in,
25- set_feature_flag,
26 TestCaseWithFactory,
27 )
28 from lp.testing.views import create_initialized_view
29
30
31+ON = 'on'
32+OFF = None
33+
34+
35 class BugSubscriptionAdvancedFeaturesTestCase(TestCaseWithFactory):
36
37 layer = LaunchpadFunctionalLayer
38+ feature_flag = 'malone.advanced-subscriptions.enabled'
39
40 def setUp(self):
41 super(BugSubscriptionAdvancedFeaturesTestCase, self).setUp()
42 self.bug = self.factory.makeBug()
43 self.person = self.factory.makePerson()
44 self.team = self.factory.makeTeam()
45- with feature_flags():
46- set_feature_flag(u'malone.advanced-subscriptions.enabled', u'on')
47
48 def test_subscribe_uses_bug_notification_level(self):
49 # When a user subscribes to a bug using the advanced features on
50@@ -48,7 +50,7 @@
51
52 # We don't display BugNotificationLevel.NOTHING as an option.
53 # This is tested below.
54- with feature_flags():
55+ with FeatureFixture({self.feature_flag: ON}):
56 displayed_levels = [
57 level for level in BugNotificationLevel.items
58 if level != BugNotificationLevel.NOTHING]
59@@ -76,7 +78,7 @@
60 # someone is trying to subscribe.
61 bug = self.factory.makeBug()
62 person = self.factory.makePerson()
63- with feature_flags():
64+ with FeatureFixture({self.feature_flag: ON}):
65 with person_logged_in(person):
66 level = BugNotificationLevel.NOTHING
67 harness = LaunchpadFormHarness(
68@@ -98,7 +100,7 @@
69 # BugSubscriptionSubscribeSelfView.
70 bug = self.factory.makeBug()
71 person = self.factory.makePerson()
72- with feature_flags():
73+ with FeatureFixture({self.feature_flag: ON}):
74 with person_logged_in(person):
75 bug.subscribe(person, person, BugNotificationLevel.COMMENTS)
76 # Now the person updates their subscription so they're
77@@ -125,7 +127,7 @@
78 # BugSubscriptionSubscribeSelfView.
79 bug = self.factory.makeBug()
80 person = self.factory.makePerson()
81- with feature_flags():
82+ with FeatureFixture({self.feature_flag: ON}):
83 with person_logged_in(person):
84 bug.subscribe(person, person)
85 harness = LaunchpadFormHarness(
86@@ -147,7 +149,7 @@
87 # level.
88 bug = self.factory.makeBug()
89 person = self.factory.makePerson()
90- with feature_flags():
91+ with FeatureFixture({self.feature_flag: ON}):
92 with person_logged_in(person):
93 # We subscribe using the harness rather than doing it
94 # directly so that we don't have to commit() between
95@@ -183,9 +185,8 @@
96 # subscription that doesn't exist).
97 bug = self.factory.makeBug()
98 person = self.factory.makePerson()
99- with feature_flags():
100+ with FeatureFixture({self.feature_flag: ON}):
101 with person_logged_in(person):
102- level = BugNotificationLevel.METADATA
103 harness = LaunchpadFormHarness(
104 bug.default_bugtask, BugSubscriptionSubscribeSelfView)
105 subscription_field = (
106@@ -202,10 +203,9 @@
107 bug = self.factory.makeBug()
108 person = self.factory.makePerson()
109 team = self.factory.makeTeam(owner=person)
110- with feature_flags():
111+ with FeatureFixture({self.feature_flag: ON}):
112 with person_logged_in(person):
113 bug.subscribe(team, person)
114- level = BugNotificationLevel.METADATA
115 harness = LaunchpadFormHarness(
116 bug.default_bugtask, BugSubscriptionSubscribeSelfView)
117 subscription_field = (
118@@ -224,13 +224,12 @@
119 duplicate = self.factory.makeBug()
120 person = self.factory.makePerson()
121 team = self.factory.makeTeam(owner=person)
122- with feature_flags():
123+ with FeatureFixture({self.feature_flag: ON}):
124 with person_logged_in(person):
125 duplicate.markAsDuplicate(bug)
126 duplicate.subscribe(person, person)
127 bug.subscribe(team, person)
128
129- level = BugNotificationLevel.METADATA
130 harness = LaunchpadFormHarness(
131 bug.default_bugtask, BugSubscriptionSubscribeSelfView)
132 subscription_field = (
133@@ -246,7 +245,7 @@
134 bug = self.factory.makeBug()
135 duplicate = self.factory.makeBug()
136 person = self.factory.makePerson()
137- with feature_flags():
138+ with FeatureFixture({self.feature_flag: ON}):
139 with person_logged_in(person):
140 duplicate.markAsDuplicate(bug)
141 duplicate.subscribe(person, person)
142@@ -264,10 +263,10 @@
143 bug = self.factory.makeBug()
144 person = self.factory.makePerson()
145 with person_logged_in(person):
146- subscription = bug.subscribe(
147+ bug.subscribe(
148 person, person, level=BugNotificationLevel.NOTHING)
149
150- with feature_flags():
151+ with FeatureFixture({self.feature_flag: ON}):
152 with person_logged_in(person):
153 subscribe_view = create_initialized_view(
154 bug.default_bugtask, name='+subscribe')
155@@ -287,7 +286,7 @@
156 with person_logged_in(self.person):
157 self.bug.mute(self.person, self.person)
158
159- with feature_flags():
160+ with FeatureFixture({self.feature_flag: ON}):
161 with person_logged_in(self.person):
162 subscribe_view = create_initialized_view(
163 self.bug.default_bugtask, name='+subscribe')
164@@ -307,7 +306,7 @@
165 with person_logged_in(self.person):
166 self.bug.mute(self.person, self.person)
167
168- with feature_flags():
169+ with FeatureFixture({self.feature_flag: ON}):
170 with person_logged_in(self.person):
171 subscribe_view = create_initialized_view(
172 self.bug.default_bugtask, name='+subscribe')
173@@ -325,7 +324,7 @@
174 with person_logged_in(self.person):
175 self.bug.mute(self.person, self.person)
176
177- with feature_flags():
178+ with FeatureFixture({self.feature_flag: ON}):
179 with person_logged_in(self.person):
180 level = BugNotificationLevel.METADATA
181 form_data = {
182@@ -335,7 +334,7 @@
183 'field.bug_notification_level': level.title,
184 'field.actions.continue': 'Continue',
185 }
186- subscribe_view = create_initialized_view(
187+ create_initialized_view(
188 self.bug.default_bugtask, form=form_data,
189 name='+subscribe')
190 self.assertFalse(self.bug.isMuted(self.person))
191@@ -348,7 +347,7 @@
192 with person_logged_in(self.person):
193 muted_subscription = self.bug.mute(self.person, self.person)
194
195- with feature_flags():
196+ with FeatureFixture({self.feature_flag: ON}):
197 with person_logged_in(self.person):
198 level = BugNotificationLevel.COMMENTS
199 form_data = {
200@@ -356,7 +355,7 @@
201 'field.bug_notification_level': level.title,
202 'field.actions.continue': 'Continue',
203 }
204- subscribe_view = create_initialized_view(
205+ create_initialized_view(
206 self.bug.default_bugtask, form=form_data,
207 name='+subscribe')
208 self.assertFalse(self.bug.isMuted(self.person))
209@@ -368,7 +367,7 @@
210 # The bug_notification_level widget has a widget_class property
211 # that can be used to manipulate it with JavaScript.
212 with person_logged_in(self.person):
213- with feature_flags():
214+ with FeatureFixture({self.feature_flag: ON}):
215 subscribe_view = create_initialized_view(
216 self.bug.default_bugtask, name='+subscribe')
217 widget_class = (
218@@ -377,6 +376,40 @@
219 'bug-notification-level-field', widget_class)
220
221
222+class BugSubscriptionAdvancedFeaturesPortletTestCase(TestCaseWithFactory):
223+
224+ layer = LaunchpadFunctionalLayer
225+ feature_flag = 'malone.advanced-subscriptions.enabled'
226+
227+ def setUp(self):
228+ super(BugSubscriptionAdvancedFeaturesPortletTestCase, self).setUp()
229+ self.bug = self.factory.makeBug()
230+ self.person = self.factory.makePerson()
231+ self.target = self.bug.default_bugtask.target
232+ subscriber = self.factory.makePerson()
233+ with person_logged_in(self.person):
234+ self.target.addBugSubscription(subscriber, subscriber)
235+
236+ def get_contents(self, flag):
237+ with person_logged_in(self.person):
238+ with FeatureFixture({self.feature_flag: flag}):
239+ bug_view = create_initialized_view(
240+ self.bug, name="+bug-portlet-subscribers-content")
241+ return bug_view.render()
242+
243+ def test_also_notified_suppressed(self):
244+ # If the advanced-subscription.enabled feature flag is on then the
245+ # "Also notified" portion of the portlet is suppressed.
246+ contents = self.get_contents(ON)
247+ self.assertFalse('Also notified' in contents)
248+
249+ def test_also_notified_not_suppressed(self):
250+ # If the advanced-subscription.enabled feature flag is off then the
251+ # "Also notified" portion of the portlet is shown.
252+ contents = self.get_contents(OFF)
253+ self.assertTrue('Also notified' in contents)
254+
255+
256 class BugPortletSubcribersIdsTests(TestCaseWithFactory):
257
258 layer = LaunchpadFunctionalLayer
259@@ -410,7 +443,7 @@
260 def test_form_initializes(self):
261 # It's a start.
262 with person_logged_in(self.subscriber):
263- sub = self.product.addBugSubscription(
264+ self.product.addBugSubscription(
265 self.subscriber, self.subscriber)
266 harness = LaunchpadFormHarness(
267 self.bug.default_bugtask, BugSubscriptionListView)
268@@ -460,7 +493,7 @@
269 # its form is submitted.
270 with person_logged_in(self.person):
271 self.assertFalse(self.bug.isMuted(self.person))
272- mute_view = create_initialized_view(
273+ create_initialized_view(
274 self.bug.default_bugtask, name="+mute",
275 form={'field.actions.mute': 'Mute bug mail'})
276 self.assertTrue(self.bug.isMuted(self.person))
277
278=== modified file 'lib/lp/bugs/templates/bug-portlet-subscribers-content.pt'
279--- lib/lp/bugs/templates/bug-portlet-subscribers-content.pt 2011-02-03 05:14:54 +0000
280+++ lib/lp/bugs/templates/bug-portlet-subscribers-content.pt 2011-04-21 18:31:32 +0000
281@@ -6,7 +6,6 @@
282 tal:define="
283 bug context/bug|context;
284 direct_subscriptions view/sorted_direct_subscriptions;
285- also_notified_subscribers bug/getAlsoNotifiedSubscribers
286 ">
287 <div class="section" id="subscribers-direct">
288 <h2>Subscribers</h2>
289@@ -57,15 +56,18 @@
290 <img src="/@@/spinner" />
291 </div>
292 </div>
293- <div
294- tal:condition="also_notified_subscribers"
295- id="subscribers-indirect"
296- class="Section"
297- >
298- <h2>Also notified</h2>
299+ <tal:also_notified condition="not: request/features/malone.advanced-subscriptions.enabled">
300 <div
301- tal:repeat="subscriber also_notified_subscribers"
302- tal:content="structure subscriber/fmt:link"
303- />
304- </div>
305+ tal:define="also_notified_subscribers bug/getAlsoNotifiedSubscribers"
306+ tal:condition="also_notified_subscribers"
307+ id="subscribers-indirect"
308+ class="Section"
309+ >
310+ <h2>Also notified</h2>
311+ <div
312+ tal:repeat="subscriber also_notified_subscribers"
313+ tal:content="structure subscriber/fmt:link"
314+ />
315+ </div>
316+ </tal:also_notified>
317 </div>