Merge lp:~wgrant/launchpad/fix-team-unsubscription-bug-415229 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/fix-team-unsubscription-bug-415229
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~wgrant/launchpad/fix-team-unsubscription-bug-415229
Reviewer Review Type Date Requested Status
Graham Binns (community) code js Approve
Review via email: mp+10300@code.launchpad.net
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

= Summary =

Links in the subscribers portlet were previously just paths (/~someperson), but now include the mainsite domain (https://launchpad.dev/~someperson). The inline unsubscription JS assumes the old style, so is broken.

Only the last revision is really in this branch; the others are in lp:~wgrant/launchpad/fix-ajax-subscription-bug-41516 which is approved for landing.

== Proposed fix ==

The URL is retrieved with get_user_uri_from_icon, so my fix strips the domain off there. This returns the behaviour of the function to the original, so the rest of the JS works as before.

== Pre-implementation notes ==

BjornT agreed that the correct fix was to strip the domain off, and suggested that it be done inside get_user_uri_from_icon.

== Implementation details ==

See above.

== Tests ==

There's just a somewhat flaky Windmill test:

 $ ./bin/lp-windmill -e test=lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py firefox http://bugs.launchpad.dev:8085

== Demo and Q/A ==

To Q/A:

 * Log on as any user.
 * Navigate to a bug.
 * Subscribe a team of which you are a member.
 * Without refreshing, click on the unsubscribe link next to it.
 * Verify that you were unsubscribed via AJAX.
 * Repeat the above, but refreshing before clicking the unsubscribe link.

Revision history for this message
Graham Binns (gmb) wrote :

Hi William,

This all looks good. r=me.

review: Approve (code js)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/tales.txt'
2--- lib/canonical/launchpad/doc/tales.txt 2009-08-13 21:32:59 +0000
3+++ lib/canonical/launchpad/doc/tales.txt 2009-08-18 05:00:54 +0000
4@@ -289,6 +289,30 @@
5 >>> login(ANONYMOUS)
6
7
8+The fmt: namespace to get a web service URL
9+-------------------------------------------
10+
11+The `fmt:api_url` expression gives you the absolute API path to an object.
12+This path is everything after the web service version number.
13+
14+ >>> login(ANONYMOUS,
15+ ... LaunchpadTestRequest(SERVER_URL='http://bugs.launchpad.net'))
16+
17+ >>> bob = factory.makePerson(name='bob')
18+ >>> print test_tales("person/fmt:api_url", person=bob)
19+ /~bob
20+
21+ >>> freewidget = factory.makeProduct(name='freewidget')
22+ >>> print test_tales("product/fmt:api_url", product=freewidget)
23+ /freewidget
24+
25+ >>> debuntu = factory.makeProduct(name='debuntu')
26+ >>> print test_tales("distro/fmt:api_url", distro=debuntu)
27+ /debuntu
28+
29+ >>> login(ANONYMOUS)
30+
31+
32 The fmt: namespace to get links
33 -------------------------------
34
35@@ -456,20 +480,22 @@
36 Branch subscriptions show the person and branch name. For users without
37 adequate permissions, a link is not generated.
38
39- >>> branch = factory.makeAnyBranch(title='My Branch')
40- >>> person = factory.makePerson(displayname='My Person')
41+ >>> branch = factory.makeProductBranch(
42+ ... owner=eric, product=fooix, name='my-branch', title='My Branch')
43+ >>> michael = factory.makePerson(
44+ ... name='michael', displayname='Michael the Viking')
45 >>> subscription = factory.makeBranchSubscription(
46- ... branch=branch, person=person)
47+ ... branch=branch, person=michael)
48 >>> test_tales("subscription/fmt:link", subscription=subscription)
49- u'Subscription of My Person to
50- lp://dev/~person-name17/product-name12/branch19'
51+ u'Subscription of Michael the Viking to
52+ lp://dev/~eric/fooix/my-branch'
53
54 But if we log in as the subscriber, a link is presented.
55
56 >>> login_person(subscription.person)
57 >>> test_tales("subscription/fmt:link", subscription=subscription)
58- u'<a href="http://.../+subscription/person-name21">Subscription
59- of My Person to lp://dev/~person-name17/product-name12/branch19</a>'
60+ u'<a href="http://.../+subscription/michael">Subscription
61+ of Michael the Viking to lp://dev/~eric/fooix/my-branch</a>'
62
63 Merge proposals also have a link formatter, which displays branch
64 titles:
65
66=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
67--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-08-10 12:12:00 +0000
68+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-08-18 09:33:20 +0000
69@@ -664,6 +664,14 @@
70 // and cross-browser issues, using the YUI query syntax is
71 // safer here.
72 var user_uri = parent_div.query('a').getAttribute('href');
73+
74+ // Strip the domain off. We just want a path.
75+ var host_start = user_uri.indexOf('//');
76+ if (host_start != -1) {
77+ var host_end = user_uri.indexOf('/', host_start+2);
78+ return user_uri.substring(host_end, user_uri.length);
79+ }
80+
81 return user_uri;
82 }
83
84
85=== modified file 'lib/canonical/launchpad/webapp/tales.py'
86--- lib/canonical/launchpad/webapp/tales.py 2009-08-14 12:56:19 +0000
87+++ lib/canonical/launchpad/webapp/tales.py 2009-08-18 05:03:00 +0000
88@@ -455,7 +455,10 @@
89 version number. It's the same as 'url', but without any view
90 name.
91 """
92- return self.url()
93+
94+ # Some classes override the rootsite. We always want a path-only
95+ # URL, so we override it to nothing.
96+ return self.url(rootsite=None)
97
98 def traverse(self, name, furtherPath):
99 if name.startswith('link:') or name.startswith('url:'):