Merge lp:~michael.nelson/launchpad/522517-multiple-subscriptions-displayed into lp:launchpad

Proposed by Michael Nelson
Status: Merged
Approved by: Muharem Hrnjadovic
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~michael.nelson/launchpad/522517-multiple-subscriptions-displayed
Merge into: lp:launchpad
Diff against target: 121 lines (+51/-14)
2 files modified
lib/lp/soyuz/browser/archivesubscription.py (+20/-6)
lib/lp/soyuz/stories/ppa/xx-private-ppa-subscriptions.txt (+31/-8)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/522517-multiple-subscriptions-displayed
Reviewer Review Type Date Requested Status
Muharem Hrnjadovic (community) Approve
Review via email: mp+20567@code.launchpad.net

Commit message

Only unique PersonArchiveSubscriptions are displayed.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

This branch fixes bug 522517.

It just adds a test to reproduce the issue and then ensures that only unique personal archive subscriptions are displayed on a page.

To test:
bin/test -vvt xx-private-ppa-subscriptions.txt

Lint:

There are three lint items in browser/archivesubscriptions.py but I've fixed those in a separate branch already (which I can't set as a pre-req. for this one).

Revision history for this message
Muharem Hrnjadovic (al-maisan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/archivesubscription.py'
2--- lib/lp/soyuz/browser/archivesubscription.py 2009-09-29 07:21:40 +0000
3+++ lib/lp/soyuz/browser/archivesubscription.py 2010-03-08 08:50:44 +0000
4@@ -298,12 +298,26 @@
5 self.context)
6
7 # Turn the result set into a list of dicts so it can be easily
8- # accessed in TAL:
9- return [
10- dict(subscription=PersonalArchiveSubscription(self.context,
11- subscr.archive),
12- token=token)
13- for subscr, token in subs_with_tokens]
14+ # accessed in TAL. Note that we need to ensure that only one
15+ # PersonalArchiveSubscription is included for each archive,
16+ # as the person might have participation in multiple
17+ # subscriptions (via different teams).
18+ unique_archives = set()
19+ personal_subscription_tokens = []
20+ for subscription, token in subs_with_tokens:
21+ if subscription.archive in unique_archives:
22+ continue
23+
24+ unique_archives.add(subscription.archive)
25+
26+ personal_subscription = PersonalArchiveSubscription(
27+ self.context, subscription.archive)
28+ personal_subscription_tokens.append({
29+ 'subscription': personal_subscription,
30+ 'token': token
31+ })
32+
33+ return personal_subscription_tokens
34
35
36 class PersonArchiveSubscriptionView(LaunchpadView):
37
38=== modified file 'lib/lp/soyuz/stories/ppa/xx-private-ppa-subscriptions.txt'
39--- lib/lp/soyuz/stories/ppa/xx-private-ppa-subscriptions.txt 2010-02-24 15:52:53 +0000
40+++ lib/lp/soyuz/stories/ppa/xx-private-ppa-subscriptions.txt 2010-03-08 08:50:44 +0000
41@@ -70,21 +70,23 @@
42 ... 'no-subscribers'))
43 No one has access to install software from this PPA.
44
45-Create two new users that can be subscribed to archives:
46+Create two new users that can be subscribed to archives, and a team:
47
48 >>> login('foo.bar@canonical.com')
49 >>> joesmith = factory.makePerson(name="joesmith", displayname="Joe Smith",
50 ... password="test", email="joe@example.com")
51+ >>> teamjoe = factory.makeTeam(
52+ ... owner=joesmith, displayname="Team Joe", name='teamjoe')
53 >>> bradsmith = factory.makePerson(name="bradsmith", displayname="Brad Smith",
54 ... password="test", email="brad@example.com")
55 >>> logout()
56
57-People can be subscribed by entering their details into the displayed
58-form:
59+People and teams can be subscribed by entering their details into the
60+displayed form:
61
62- >>> cprov_browser.getControl(name='field.subscriber').value = 'joesmith'
63+ >>> cprov_browser.getControl(name='field.subscriber').value = 'teamjoe'
64 >>> cprov_browser.getControl(
65- ... name='field.description').value = "Joe is my friend"
66+ ... name='field.description').value = "Joes friends are my friends"
67 >>> cprov_browser.getControl(name="field.actions.add").click()
68 >>> cprov_browser.getControl(name='field.subscriber').value = 'bradsmith'
69 >>> cprov_browser.getControl(
70@@ -100,7 +102,7 @@
71 ... print extract_text(row)
72 Name Expires Comment
73 Brad Smith 2200-08-01 Brad can access for a while. Edit/Cancel
74- Joe Smith Joe is my friend Edit/Cancel
75+ Team Joe Joes friends are my friends Edit/Cancel
76
77
78 == Managing a persons' Archive subscriptions ==
79@@ -120,8 +122,8 @@
80 >>> print extract_text(explanation)
81 You do not have any current subscriptions to private archives...
82
83-First, create a subscription for Joe Smith to mark's archive also, so that
84-Joe has multiple subscriptions:
85+First, create a subscription for Joe Smith's team to mark's archive
86+so that Joe has multiple subscriptions:
87
88 >>> mark_browser = setupBrowser(
89 ... auth="Basic mark@example.com:test")
90@@ -144,6 +146,7 @@
91 PPA named... (ppa:mark/p3a) Mark Shuttleworth View
92 PPA named... (ppa:cprov/p3a) Celso Providelo View
93
94+
95 == Confirming a subscription ==
96
97 When a person clicks on the view button, the subscription is confirmed
98@@ -187,3 +190,23 @@
99 to PPA named p3a for Mark Shuttleworth
100 This repository is signed ...
101
102+Once a person has activated a subscription, being subscribed again via
103+another team does not lead to duplicate entries on the person's
104+subscriptions page.
105+
106+ >>> mark_browser.open("http://launchpad.dev/~mark/+archive/p3a")
107+ >>> mark_browser.getLink("Manage access").click()
108+ >>> mark_browser.getControl(name='field.subscriber').value = 'teamjoe'
109+ >>> mark_browser.getControl(
110+ ... name='field.description').value = "Joe's friends are my friends."
111+ >>> mark_browser.getControl(name="field.actions.add").click()
112+ >>> joe_browser.open(
113+ ... "http://launchpad.dev/~joesmith/+archivesubscriptions")
114+ >>> rows = find_tags_by_class(
115+ ... joe_browser.contents, 'archive-subscription-row')
116+ >>> for row in rows:
117+ ... print extract_text(row)
118+ Archive Owner
119+ PPA named p3a for Mark Shuttleworth (ppa:mark/p3a) Mark Shuttleworth View
120+ PPA named p3a for Celso Providelo (ppa:cprov/p3a) Celso Providelo View
121+