Merge lp:~gmb/launchpad/subscriber-portlet-timeout-bug-393476 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~gmb/launchpad/subscriber-portlet-timeout-bug-393476
Merge into: lp:launchpad
Diff against target: 521 lines (+191/-95)
11 files modified
lib/canonical/launchpad/javascript/bugs/bugtask-index.js (+71/-4)
lib/lp/bugs/browser/bugsubscription.py (+9/-2)
lib/lp/bugs/browser/configure.zcml (+6/-0)
lib/lp/bugs/browser/tests/bug-portlet-subscribers-content.txt (+1/-1)
lib/lp/bugs/stories/bug-privacy/05-set-bug-private-as-admin.txt (+6/-3)
lib/lp/bugs/stories/bugs/bug-add-subscriber.txt (+4/-2)
lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt (+35/-16)
lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt (+27/-0)
lib/lp/bugs/templates/bug-portlet-subscribers-content.pt (+8/-17)
lib/lp/bugs/templates/bug-portlet-subscribers.pt (+16/-46)
lib/lp/bugs/tests/bug.py (+8/-4)
To merge this branch: bzr merge lp:~gmb/launchpad/subscriber-portlet-timeout-bug-393476
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+14502@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :
Download full text (3.4 KiB)

This branch fixes bug 393476 (subscribers portlet times out) by loading
the subscribers from duplicates separately from the main set of
subscribers.

Most bugs have a relatively low number of direct subscribers, but a bug
with a large number of duplicates can have thousands of indirect ones.
Loading these indirect subscribers can sometimes time out because of the
large number of subscribers and because in order to display them we need
to iterate over the result set before rendering the page.

My solution is to load the subscribers from duplicates separately.
Whilst we could spend time optimising the query and the iterations over
the result set, there will come a point where, for bugs with large
numbers of indirect subscribers, there will simply be too many to
handle. In those cases it's important that we still render the list of
direct subscribers (because that's usually the most interesting list of
subscribers on a bug page) and, most importantly, that we set up the
subscribe and unsubscribe links properly (at the moment the timeout
causes the AJAX controls to never get set up).

== Changes ==

=== lib/canonical/launchpad/javascript/bugs/bugtask-index.js ===

 - I've added two functions here. load_subscribers_from_duplicates()
   does the asynchronous loading of subs from dupes and
   Y.bugs.load_subscribers_portlet() contains the subs portlet setup
   code that was previously inline in the portlet template.
 - load_subscribers_from_duplicates() is now called once the
   portletloaded event is fired, meaning that it only happens once the
   direct subscribers have been loaded and the links have been set up
   correctly.

=== lib/lp/bugs/browser/bugsubscription.py ===

 - I've refactored the existing BugPortletSubcribersContents view into
   two views: BugPortletSubcribersContents and
   BugPortletDuplicateSubcribersContents. The second deals with the
   subs from dupes list.
 - I've updated the methods used in these views to turn them into
   @properties, per the coding standards.

=== lib/lp/bugs/browser/configure.zcml ===

 - I've added an entry for the BugPortletDuplicateSubcribersContents
   view.

=== lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt ===

 - I've added this template that displays only the list of subscribers
   from duplicates.

=== lib/lp/bugs/templates/bug-portlet-subscribers-content.pt ===

 - I've updated the existing template to remove the subs from dupes
   code.

=== lib/lp/bugs/templates/bug-portlet-subscribers.pt ===

 - I've removed the inline JS that didn't need to be inline, fixing bug
   369874 as a drive-by.

== Launchpad lint ==

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/javascript/bugs/bugtask-index.js
  lib/lp/bugs/browser/bugsubscription.py
  lib/lp/bugs/browser/configure.zcml
  lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt
  lib/lp/bugs/templates/bug-portlet-subscribers-content.pt
  lib/lp/bugs/templates/bug-portlet-subscribers.pt

== JSLint notices ==
jslint: No problem found in '/home/graham/canonical/lp-branches/subscriber-portlet-t...

Read more...

Revision history for this message
Abel Deuring (adeuring) wrote :

looks good

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-11-03 14:41:35 +0000
+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-11-08 11:19:16 +0000
@@ -46,15 +46,13 @@
46 * depends on that portlet being loaded, setup a custom46 * depends on that portlet being loaded, setup a custom
47 * event object, to provide a hook for initializing subscription47 * event object, to provide a hook for initializing subscription
48 * link callbacks after a bugs:portletloaded event.48 * link callbacks after a bugs:portletloaded event.
49 *49 */
50 * XXX deryck 2009-04-30 bug=369874 Now this object exists,
51 * the inline js on bug-portlet-subscribers.pt should be moved here.
52*/
53var PortletTarget = function() {};50var PortletTarget = function() {};
54Y.augment(PortletTarget, Y.Event.Target);51Y.augment(PortletTarget, Y.Event.Target);
55Y.bugs.portlet = new PortletTarget();52Y.bugs.portlet = new PortletTarget();
56Y.bugs.portlet.subscribe('bugs:portletloaded', function() {53Y.bugs.portlet.subscribe('bugs:portletloaded', function() {
57 setup_subscription_link_handlers();54 setup_subscription_link_handlers();
55 load_subscribers_from_duplicates();
58});56});
59/*57/*
60 * If the subscribers portlet fails to load, clear any58 * If the subscribers portlet fails to load, clear any
@@ -1719,6 +1717,75 @@
1719 });1717 });
1720}1718}
17211719
1720function load_subscribers_from_duplicates() {
1721 if (Y.UA.ie) {
1722 return null;
1723 }
1724
1725 Y.get('#subscribers-portlet-dupe-spinner').setStyle(
1726 'display', 'block');
1727
1728 function hide_spinner() {
1729 Y.get('#subscribers-portlet-dupe-spinner').setStyle(
1730 'display', 'none');
1731 }
1732
1733 function on_success(transactionid, response, args) {
1734 hide_spinner();
1735
1736 var dupe_subscribers_container = Y.get(
1737 '#subscribers-from-duplicates-container');
1738 dupe_subscribers_container.set(
1739 'innerHTML',
1740 dupe_subscribers_container.get('innerHTML') +
1741 response.responseText);
1742 }
1743
1744 var config = {on: {success: on_success,
1745 failure: hide_spinner}};
1746 var url = Y.get(
1747 '#subscribers-from-dupes-content-link').getAttribute(
1748 'href').replace('bugs.', '');
1749 Y.io(url, config);
1750}
1751
1752Y.bugs.load_subscribers_portlet = function(
1753 subscription_link, subscription_link_handler) {
1754 if (Y.UA.ie) {
1755 return null;
1756 }
1757
1758 Y.get('#subscribers-portlet-spinner').setStyle('display', 'block');
1759
1760 function hide_spinner() {
1761 Y.get('#subscribers-portlet-spinner').setStyle('display', 'none');
1762 // Fire a custom event to notify that the initial click
1763 // handler on subscription_link set above should be
1764 // cleared.
1765 if (Y.bugs) {
1766 Y.bugs.portlet.fire(
1767 'bugs:portletloadfailed', subscription_link_handler);
1768 }
1769 }
1770
1771 function on_success(transactionid, response, args) {
1772 hide_spinner();
1773 var portlet = Y.get('#portlet-subscribers');
1774 portlet.set('innerHTML',
1775 portlet.get('innerHTML') + response.responseText);
1776
1777 // Fire a custom portlet loaded event to notify when
1778 // it's safe to setup subscriber link callbacks.
1779 Y.bugs.portlet.fire('bugs:portletloaded');
1780 }
1781
1782 var config = {on: {success: on_success,
1783 failure: hide_spinner}};
1784 var url = Y.get(
1785 '#subscribers-content-link').getAttribute('href').replace('bugs.', '');
1786 Y.io(url, config);
1787};
1788
1722}, '0.1', {requires: ['base', 'oop', 'node', 'event', 'io-base', 'substitute',1789}, '0.1', {requires: ['base', 'oop', 'node', 'event', 'io-base', 'substitute',
1723 'widget-position-ext', 'lazr.formoverlay', 'lazr.anim',1790 'widget-position-ext', 'lazr.formoverlay', 'lazr.anim',
1724 'lazr.base', 'lazr.overlay', 'lazr.choiceedit',1791 'lazr.base', 'lazr.overlay', 'lazr.choiceedit',
17251792
=== modified file 'lib/lp/bugs/browser/bugsubscription.py'
--- lib/lp/bugs/browser/bugsubscription.py 2009-08-31 15:41:15 +0000
+++ lib/lp/bugs/browser/bugsubscription.py 2009-11-08 11:19:16 +0000
@@ -5,6 +5,7 @@
55
6__metaclass__ = type6__metaclass__ = type
7__all__ = [7__all__ = [
8 'BugPortletDuplicateSubcribersContents',
8 'BugPortletSubcribersContents',9 'BugPortletSubcribersContents',
9 'BugSubscriptionAddView',10 'BugSubscriptionAddView',
10 ]11 ]
@@ -61,7 +62,8 @@
61class BugPortletSubcribersContents(LaunchpadView, BugViewMixin):62class BugPortletSubcribersContents(LaunchpadView, BugViewMixin):
62 """View for the contents for the subscribers portlet."""63 """View for the contents for the subscribers portlet."""
6364
64 def getSortedDirectSubscriptions(self):65 @property
66 def sorted_direct_subscriptions(self):
65 """Get the list of direct subscriptions to the bug.67 """Get the list of direct subscriptions to the bug.
6668
67 The list is sorted such that subscriptions you can unsubscribe appear69 The list is sorted such that subscriptions you can unsubscribe appear
@@ -83,7 +85,12 @@
83 cannot_unsubscribe.append(subscription)85 cannot_unsubscribe.append(subscription)
84 return can_unsubscribe + cannot_unsubscribe86 return can_unsubscribe + cannot_unsubscribe
8587
86 def getSortedSubscriptionsFromDuplicates(self):88
89class BugPortletDuplicateSubcribersContents(LaunchpadView, BugViewMixin):
90 """View for the contents for the subscribers-from-dupes portlet block."""
91
92 @property
93 def sorted_subscriptions_from_dupes(self):
87 """Get the list of subscriptions to duplicates of this bug."""94 """Get the list of subscriptions to duplicates of this bug."""
88 return [95 return [
89 SubscriptionAttrDecorator(subscription)96 SubscriptionAttrDecorator(subscription)
9097
=== modified file 'lib/lp/bugs/browser/configure.zcml'
--- lib/lp/bugs/browser/configure.zcml 2009-10-30 12:09:16 +0000
+++ lib/lp/bugs/browser/configure.zcml 2009-11-08 11:19:16 +0000
@@ -998,6 +998,12 @@
998 class="lp.bugs.browser.bugsubscription.BugPortletSubcribersContents"998 class="lp.bugs.browser.bugsubscription.BugPortletSubcribersContents"
999 template="../templates/bug-portlet-subscribers-content.pt"999 template="../templates/bug-portlet-subscribers-content.pt"
1000 permission="zope.Public"/>1000 permission="zope.Public"/>
1001 <browser:page
1002 for="lp.bugs.interfaces.bug.IBug"
1003 name="+bug-portlet-dupe-subscribers-content"
1004 class="lp.bugs.browser.bugsubscription.BugPortletDuplicateSubcribersContents"
1005 template="../templates/bug-portlet-dupe-subscribers-content.pt"
1006 permission="zope.Public"/>
1001 <browser:navigation1007 <browser:navigation
1002 module="lp.bugs.browser.bug"1008 module="lp.bugs.browser.bug"
1003 classes="1009 classes="
10041010
=== modified file 'lib/lp/bugs/browser/tests/bug-portlet-subscribers-content.txt'
--- lib/lp/bugs/browser/tests/bug-portlet-subscribers-content.txt 2009-06-12 16:36:02 +0000
+++ lib/lp/bugs/browser/tests/bug-portlet-subscribers-content.txt 2009-11-08 11:19:16 +0000
@@ -15,7 +15,7 @@
15 <BugSubscription at ...>15 <BugSubscription at ...>
16 >>> bug.subscribe(view.user.teams_participated_in[0], view.user)16 >>> bug.subscribe(view.user.teams_participated_in[0], view.user)
17 <BugSubscription at ...>17 <BugSubscription at ...>
18 >>> for subscription in view.getSortedDirectSubscriptions():18 >>> for subscription in view.sorted_direct_subscriptions:
19 ... print '%s %s' % (19 ... print '%s %s' % (
20 ... subscription.person.displayname,20 ... subscription.person.displayname,
21 ... subscription.canBeUnsubscribedByUser(view.user))21 ... subscription.canBeUnsubscribedByUser(view.user))
2222
=== modified file 'lib/lp/bugs/stories/bug-privacy/05-set-bug-private-as-admin.txt'
--- lib/lp/bugs/stories/bug-privacy/05-set-bug-private-as-admin.txt 2009-06-12 16:36:02 +0000
+++ lib/lp/bugs/stories/bug-privacy/05-set-bug-private-as-admin.txt 2009-11-08 11:19:16 +0000
@@ -9,7 +9,8 @@
9explicit. There are two implicit subscribers.9explicit. There are two implicit subscribers.
1010
11 >>> from lp.bugs.tests.bug import (11 >>> from lp.bugs.tests.bug import (
12 ... print_direct_subscribers, print_indirect_subscribers)12 ... print_also_notified, print_direct_subscribers,
13 ... print_subscribers_from_duplicates)
1314
14 >>> browser.open(15 >>> browser.open(
15 ... "http://launchpad.dev/bugs/2/+bug-portlet-subscribers-content")16 ... "http://launchpad.dev/bugs/2/+bug-portlet-subscribers-content")
@@ -17,8 +18,9 @@
17 >>> print_direct_subscribers(browser.contents)18 >>> print_direct_subscribers(browser.contents)
18 Steve Alexander (Subscribed by Launchpad Janitor)19 Steve Alexander (Subscribed by Launchpad Janitor)
1920
20 >>> print_indirect_subscribers(browser.contents)21 >>> print_subscribers_from_duplicates(browser.contents)
21 From duplicates:22 From duplicates:
23 >>> print_also_notified(browser.contents)
22 Also notified:24 Also notified:
23 Mark Shuttleworth25 Mark Shuttleworth
24 Sample Person26 Sample Person
@@ -46,8 +48,9 @@
46 Sample Person (Subscribed by Foo Bar)48 Sample Person (Subscribed by Foo Bar)
47 Steve Alexander (Subscribed by Launchpad Janitor)49 Steve Alexander (Subscribed by Launchpad Janitor)
4850
49 >>> print_indirect_subscribers(browser.contents)51 >>> print_subscribers_from_duplicates(browser.contents)
50 From duplicates:52 From duplicates:
53 >>> print_also_notified(browser.contents)
51 Also notified:54 Also notified:
5255
53When we go back to the secrecy form, the previously set value is pre-selected.56When we go back to the secrecy form, the previously set value is pre-selected.
5457
=== modified file 'lib/lp/bugs/stories/bugs/bug-add-subscriber.txt'
--- lib/lp/bugs/stories/bugs/bug-add-subscriber.txt 2009-09-18 15:24:30 +0000
+++ lib/lp/bugs/stories/bugs/bug-add-subscriber.txt 2009-11-08 11:19:16 +0000
@@ -32,7 +32,8 @@
32currently subscribed to the bug:32currently subscribed to the bug:
3333
34 >>> from lp.bugs.tests.bug import (34 >>> from lp.bugs.tests.bug import (
35 ... print_direct_subscribers, print_indirect_subscribers)35 ... print_also_notified, print_direct_subscribers,
36 ... print_subscribers_from_duplicates)
3637
37 >>> user_browser.open(38 >>> user_browser.open(
38 ... 'http://bugs.launchpad.dev/bugs/1/'39 ... 'http://bugs.launchpad.dev/bugs/1/'
@@ -40,8 +41,9 @@
40 >>> print_direct_subscribers(user_browser.contents)41 >>> print_direct_subscribers(user_browser.contents)
41 Sample Person (Subscribed by Launchpad Janitor)42 Sample Person (Subscribed by Launchpad Janitor)
42 Steve Alexander (Subscribed by Launchpad Janitor)43 Steve Alexander (Subscribed by Launchpad Janitor)
43 >>> print_indirect_subscribers(user_browser.contents)44 >>> print_subscribers_from_duplicates(user_browser.contents)
44 From duplicates:45 From duplicates:
46 >>> print_also_notified(user_browser.contents)
45 Also notified:47 Also notified:
46 Foo Bar48 Foo Bar
47 Mark Shuttleworth49 Mark Shuttleworth
4850
=== modified file 'lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt'
--- lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt 2009-09-19 10:04:20 +0000
+++ lib/lp/bugs/stories/bugs/xx-bug-personal-subscriptions.txt 2009-11-08 11:19:16 +0000
@@ -4,7 +4,8 @@
4in the actions portlet.4in the actions portlet.
55
6 >>> from lp.bugs.tests.bug import (6 >>> from lp.bugs.tests.bug import (
7 ... print_direct_subscribers, print_indirect_subscribers)7 ... print_direct_subscribers, print_also_notified,
8 ... print_subscribers_from_duplicates)
89
9 >>> browser = setupBrowser(auth='Basic foo.bar@canonical.com:test')10 >>> browser = setupBrowser(auth='Basic foo.bar@canonical.com:test')
10 >>> browser.open('http://bugs.launchpad.dev/firefox/+bug/1')11 >>> browser.open('http://bugs.launchpad.dev/firefox/+bug/1')
@@ -183,9 +184,13 @@
183 >>> stevea_browser = setupBrowser(184 >>> stevea_browser = setupBrowser(
184 ... auth="Basic steve.alexander@ubuntulinux.com:test")185 ... auth="Basic steve.alexander@ubuntulinux.com:test")
185 >>> stevea_browser.open(186 >>> stevea_browser.open(
187 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
188 >>> print_subscribers_from_duplicates(stevea_browser.contents)
189 From duplicates:
190
191 >>> stevea_browser.open(
186 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")192 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")
187 >>> print_indirect_subscribers(stevea_browser.contents)193 >>> print_also_notified(stevea_browser.contents)
188 From duplicates:
189 Also notified:194 Also notified:
190 Mark Shuttleworth195 Mark Shuttleworth
191196
@@ -200,14 +205,11 @@
200 >>> stevea_browser.getControl("Change").click()205 >>> stevea_browser.getControl("Change").click()
201206
202 >>> stevea_browser.open(207 >>> stevea_browser.open(
203 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")208 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
204209 >>> print_subscribers_from_duplicates(stevea_browser.contents)
205 >>> print_indirect_subscribers(stevea_browser.contents)
206 From duplicates:210 From duplicates:
207 Steve Alexander (Subscribed by Launchpad Janitor)211 Steve Alexander (Subscribed by Launchpad Janitor)
208 (Unsubscribe Steve Alexander)212 (Unsubscribe Steve Alexander)
209 Also notified:
210 Mark Shuttleworth
211213
212 >>> stevea_browser.getLink(id='unsubscribe-subscriber-11').mech_link.url214 >>> stevea_browser.getLink(id='unsubscribe-subscriber-11').mech_link.url
213 '+subscribe'215 '+subscribe'
@@ -233,9 +235,13 @@
233to bug #3.)235to bug #3.)
234236
235 >>> stevea_browser.open(237 >>> stevea_browser.open(
238 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
239 >>> print_subscribers_from_duplicates(stevea_browser.contents)
240 From duplicates:
241
242 >>> stevea_browser.open(
236 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")243 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")
237 >>> print_indirect_subscribers(stevea_browser.contents)244 >>> print_also_notified(stevea_browser.contents)
238 From duplicates:
239 Also notified:245 Also notified:
240 Mark Shuttleworth246 Mark Shuttleworth
241247
@@ -256,12 +262,16 @@
256 >>> stevea_browser.getControl("Continue").click()262 >>> stevea_browser.getControl("Continue").click()
257263
258 >>> stevea_browser.open(264 >>> stevea_browser.open(
259 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")265 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
260 >>> print_indirect_subscribers(stevea_browser.contents)266 >>> print_subscribers_from_duplicates(stevea_browser.contents)
261 From duplicates:267 From duplicates:
262 Sample Person (Subscribed ...)268 Sample Person (Subscribed ...)
263 Steve Alexander (Subscribed ...) (Unsubscribe Steve Alexander)269 Steve Alexander (Subscribed ...) (Unsubscribe Steve Alexander)
264 testing Spanish team (Subscribed by Foo Bar)270 testing Spanish team (Subscribed by Foo Bar)
271
272 >>> stevea_browser.open(
273 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")
274 >>> print_also_notified(stevea_browser.contents)
265 Also notified:275 Also notified:
266 Mark Shuttleworth276 Mark Shuttleworth
267277
@@ -295,11 +305,16 @@
295 >>> foobar_browser.getControl("Subscribe user").click()305 >>> foobar_browser.getControl("Subscribe user").click()
296306
297 >>> foobar_browser.open(307 >>> foobar_browser.open(
298 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")308 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
299309
300 >>> print_indirect_subscribers(foobar_browser.contents)310 >>> print_subscribers_from_duplicates(foobar_browser.contents)
301 From duplicates:311 From duplicates:
302 Ubuntu Team (Subscribed by Foo Bar) (Unsubscribe Ubuntu Team)312 Ubuntu Team (Subscribed by Foo Bar) (Unsubscribe Ubuntu Team)
313
314 >>> foobar_browser.open(
315 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")
316
317 >>> print_also_notified(foobar_browser.contents)
303 Also notified:318 Also notified:
304 Mark Shuttleworth319 Mark Shuttleworth
305320
@@ -326,9 +341,13 @@
326(ubuntu-team is no longer an indirect subscriber.)341(ubuntu-team is no longer an indirect subscriber.)
327342
328 >>> foobar_browser.open(343 >>> foobar_browser.open(
344 ... "http://launchpad.dev/bugs/3/+bug-portlet-dupe-subscribers-content")
345 >>> print_subscribers_from_duplicates(foobar_browser.contents)
346 From duplicates:
347
348 >>> foobar_browser.open(
329 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")349 ... "http://launchpad.dev/bugs/3/+bug-portlet-subscribers-content")
330 >>> print_indirect_subscribers(foobar_browser.contents)350 >>> print_also_notified(foobar_browser.contents)
331 From duplicates:
332 Also notified:351 Also notified:
333 Mark Shuttleworth352 Mark Shuttleworth
334353
335354
=== added file 'lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt'
--- lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt 1970-01-01 00:00:00 +0000
+++ lib/lp/bugs/templates/bug-portlet-dupe-subscribers-content.pt 2009-11-08 11:19:16 +0000
@@ -0,0 +1,27 @@
1<div
2 tal:omit-tag=""
3 xmlns:tal="http://xml.zope.org/namespaces/tal"
4 xmlns:metal="http://xml.zope.org/namespaces/metal"
5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
6 tal:define="
7 bug context/bug|context;
8 from_dupes_subscriptions view/sorted_subscriptions_from_dupes;
9 ">
10 <div
11 tal:condition="from_dupes_subscriptions"
12 id="subscribers-from-duplicates"
13 class="section"
14 >
15 <h2>From duplicates</h2>
16 <div
17 tal:repeat="subscription from_dupes_subscriptions"
18 tal:attributes="
19 class subscription/css_name;
20 id string:dupe-${subscription/css_name};
21 "
22 >
23 <metal:subscriber
24 metal:use-macro="bug/@@+bug-portlet-subscribers-content/subscriber-row" />
25 </div>
26 </div>
27</div>
028
=== modified file 'lib/lp/bugs/templates/bug-portlet-subscribers-content.pt'
--- lib/lp/bugs/templates/bug-portlet-subscribers-content.pt 2009-08-03 12:53:22 +0000
+++ lib/lp/bugs/templates/bug-portlet-subscribers-content.pt 2009-11-08 11:19:16 +0000
@@ -5,8 +5,7 @@
5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
6 tal:define="6 tal:define="
7 bug context/bug|context;7 bug context/bug|context;
8 direct_subscriptions view/getSortedDirectSubscriptions;8 direct_subscriptions view/sorted_direct_subscriptions;
9 from_dupes_subscriptions view/getSortedSubscriptionsFromDuplicates;
10 also_notified_subscribers bug/getAlsoNotifiedSubscribers9 also_notified_subscribers bug/getAlsoNotifiedSubscribers
11 ">10 ">
12 <div class="section" id="subscribers-direct">11 <div class="section" id="subscribers-direct">
@@ -17,7 +16,7 @@
17 tal:repeat="subscription direct_subscriptions"16 tal:repeat="subscription direct_subscriptions"
18 tal:attributes="class subscription/css_name"17 tal:attributes="class subscription/css_name"
19 >18 >
20 <metal:subscriber metal:define-macro="subscriber-row">19 <metal:subscriber metal:define-macro="subscriber-row">
2120
22 <a21 <a
23 tal:condition="subscription/person/name|nothing"22 tal:condition="subscription/person/name|nothing"
@@ -49,20 +48,12 @@
49 <div id="none-subscribers"48 <div id="none-subscribers"
50 tal:condition="not:direct_subscriptions">None</div>49 tal:condition="not:direct_subscriptions">None</div>
51 </div>50 </div>
52 <div51 <div id="subscribers-from-duplicates-container">
53 tal:condition="from_dupes_subscriptions"52 <a id="subscribers-from-dupes-content-link"
54 id="subscribers-from-duplicates"53 tal:attributes="href bug/fmt:url/+bug-portlet-dupe-subscribers-content"></a>
55 class="section"54 <div id="subscribers-portlet-dupe-spinner"
56 >55 style="text-align: center; display: none">
57 <h2>From duplicates</h2>56 <img src="/@@/spinner" />
58 <div
59 tal:repeat="subscription from_dupes_subscriptions"
60 tal:attributes="
61 class subscription/css_name;
62 id string:dupe-${subscription/css_name};
63 "
64 >
65 <metal:subscriber metal:use-macro="template/macros/subscriber-row" />
66 </div>57 </div>
67 </div>58 </div>
68 <div59 <div
6960
=== modified file 'lib/lp/bugs/templates/bug-portlet-subscribers.pt'
--- lib/lp/bugs/templates/bug-portlet-subscribers.pt 2009-10-29 21:39:12 +0000
+++ lib/lp/bugs/templates/bug-portlet-subscribers.pt 2009-11-08 11:19:16 +0000
@@ -23,52 +23,22 @@
23 </div>23 </div>
24 <script type="text/javascript">24 <script type="text/javascript">
25 YUI().use('io-base', 'node', 'bugs.bugtask_index', function(Y) {25 YUI().use('io-base', 'node', 'bugs.bugtask_index', function(Y) {
26 // Must be done inline here to ensure the load event fires.26 // Must be done inline here to ensure the load event fires.
27 // This is a work around for a YUI3 issue with event handling.27 // This is a work around for a YUI3 issue with event handling.
28 var subscription_link = Y.get('.menu-link-subscription');28 var subscription_link = Y.get('.menu-link-subscription');
29 var subscription_link_handler;29 var subscription_link_handler;
30 if (subscription_link) {30 if (subscription_link) {
31 subscription_link_handler = subscription_link.on('click', function(e) {31 subscription_link_handler = subscription_link.on('click', function(e) {
32 e.preventDefault();32 e.preventDefault();
33 });33 });
34 }34 }
35 Y.on('domready', function() {35
36 if (Y.UA.ie) {36 Y.on('domready', function() {
37 return null;37 if (Y.bugs) {
38 }38 Y.bugs.load_subscribers_portlet(
3939 subscription_link, subscription_link_handler);
40 Y.get('#subscribers-portlet-spinner').setStyle('display', 'block');40 }
4141 });
42 function hide_spinner() {
43 Y.get('#subscribers-portlet-spinner').setStyle('display', 'none');
44 // Fire a custom event to notify that the initial click handler
45 // on subscription_link set above should be cleared.
46 if (Y.bugs) {
47 Y.bugs.portlet.fire(
48 'bugs:portletloadfailed', subscription_link_handler);
49 }
50 }
51
52 function on_success(transactionid, response, arguments) {
53 hide_spinner();
54 var portlet = Y.get('#portlet-subscribers');
55 portlet.set('innerHTML',
56 portlet.get('innerHTML') + response.responseText);
57 // Fire a custom portlet loaded event to notify when
58 // it's safe to setup subscriber link callbacks.
59 // XXX deryck 2009-04-30 bug=369874 Now this object exists,
60 // the inline js here should be moved to bugtask-index.js.
61 // Moving will also prevent having the paranoia check for Y.bugs.
62 if (Y.bugs) {
63 Y.bugs.portlet.fire('bugs:portletloaded');
64 }
65 }
66
67 var config = {on: {success: on_success,
68 failure: hide_spinner}};
69 var url = Y.get('#subscribers-content-link').getAttribute('href').replace('bugs.', '');
70 Y.io(url, config);
71 });
72 });42 });
73 </script>43 </script>
74</div>44</div>
7545
=== modified file 'lib/lp/bugs/tests/bug.py'
--- lib/lp/bugs/tests/bug.py 2009-08-18 11:04:38 +0000
+++ lib/lp/bugs/tests/bug.py 2009-11-08 11:19:16 +0000
@@ -33,12 +33,16 @@
33 print_subscribers(bug_page, 'subscribers-direct')33 print_subscribers(bug_page, 'subscribers-direct')
3434
3535
36def print_indirect_subscribers(bug_page):36def print_also_notified(bug_page):
37 """Print the indirect subscribers listed in a portlet."""37 """Print the structural subscribers listed in a portlet."""
38 print 'Also notified:'
39 print_subscribers(bug_page, 'subscribers-indirect')
40
41
42def print_subscribers_from_duplicates(bug_page):
43 """Print the subscribers from duplicates listed in a portlet."""
38 print 'From duplicates:'44 print 'From duplicates:'
39 print_subscribers(bug_page, 'subscribers-from-duplicates')45 print_subscribers(bug_page, 'subscribers-from-duplicates')
40 print 'Also notified:'
41 print_subscribers(bug_page, 'subscribers-indirect')
4246
4347
44def print_subscribers(bug_page, subscriber_list_id):48def print_subscribers(bug_page, subscriber_list_id):