Merge lp:~brian-murray/launchpad/subscribe-oops-bug-636412 into lp:launchpad

Proposed by Brian Murray
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11560
Proposed branch: lp:~brian-murray/launchpad/subscribe-oops-bug-636412
Merge into: lp:launchpad
Diff against target: 85 lines (+49/-0)
3 files modified
lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt (+30/-0)
lib/lp/registry/browser/structuralsubscription.py (+4/-0)
lib/lp/registry/templates/structural-subscriptions-manage.pt (+15/-0)
To merge this branch: bzr merge lp:~brian-murray/launchpad/subscribe-oops-bug-636412
Reviewer Review Type Date Requested Status
Curtis Hovey (community) ui Approve
Māris Fogels (community) Approve
Review via email: mp+35459@code.launchpad.net

Commit message

Don't display the +subscribe form for bug targets for people who cannot subscribe to the bug target.

Description of the change

Although the +subscribe link is no longer being displayed for distributions with a bug supervisor it seems that some people are still making it to launchpad.net/ubuntu/+subscribe and generating Oops reports by trying to subscribe.

To fix this I've made the form and the text preceding it conditional on whether or not one has the permission to subscribe to the bug reports about the bug target.

I've also added a test for this to xx-bug-subscriptions.txt.

To post a comment you must log in.
Revision history for this message
Māris Fogels (mars) wrote :

Hi Brian,

This change looks good. r=mars.

May I suggest a small tweak to the wording to mention the reason why we are protecting the users from our system? Something like this:

    You are unable to subscribe to bug reports about the Ubuntu project because it generates too much bug-related e-mail for most users to cope with.

    If you really want to subscribe this project's bugmail then please contact the Ubuntu project bug supervisor.

Best,

Maris

review: Approve
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thanks for addressing this oops. This looks good to land.

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt'
2--- lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt 2010-05-21 04:38:42 +0000
3+++ lib/lp/bugs/stories/structural-subscriptions/xx-bug-subscriptions.txt 2010-09-16 13:11:49 +0000
4@@ -194,3 +194,33 @@
5 >>> anon_browser.open('http://launchpad.dev/bzr')
6 >>> print anon_browser.title
7 Bazaar Version Control System in Launchpad
8+
9+== Distribution with a bug supervisor ==
10+
11+If a distribution has a bug supervisor only that team or members of it can
12+subscribe to all of the distribution's bugs.
13+
14+First, check the page content for a distribution without a bug supervisor.
15+
16+ >>> browser.open('http://bugs.launchpad.dev/ubuntu/+subscribe')
17+ >>> text_contents = extract_text(find_main_content(browser.contents))
18+ >>> "You can choose to receive an e-mail every time" in text_contents
19+ True
20+
21+Set a bug supervisor for Ubuntu.
22+
23+ >>> from zope.security.proxy import removeSecurityProxy
24+ >>> login('foo.bar@canonical.com')
25+ >>> ubuntu = removeSecurityProxy(getUtility(IDistributionSet).get(1))
26+ >>> guadamen = getUtility(IPersonSet).getByName('guadamen')
27+ >>> ubuntu.bug_supervisor = guadamen
28+ >>> flush_database_updates()
29+ >>> logout()
30+
31+Second, check that the page content for a distribution with a bug supervisor
32+contains a message about not being able to subscribe.
33+
34+ >>> browser.open('http://bugs.launchpad.dev/ubuntu/+subscribe')
35+ >>> text_contents = extract_text(find_main_content(browser.contents))
36+ >>> "You are unable to subscribe to bug reports about" in text_contents
37+ True
38
39=== modified file 'lib/lp/registry/browser/structuralsubscription.py'
40--- lib/lp/registry/browser/structuralsubscription.py 2010-08-24 10:45:57 +0000
41+++ lib/lp/registry/browser/structuralsubscription.py 2010-09-16 13:11:49 +0000
42@@ -172,6 +172,10 @@
43 """Return True, if the current user is subscribed."""
44 return self.isSubscribed(self.user)
45
46+ def userCanAlter(self):
47+ if self.context.userCanAlterBugSubscription(self.user, self.user):
48+ return True
49+
50 @action(u'Save these changes', name='save')
51 def save_action(self, action, data):
52 """Process the subscriptions submitted by the user."""
53
54=== modified file 'lib/lp/registry/templates/structural-subscriptions-manage.pt'
55--- lib/lp/registry/templates/structural-subscriptions-manage.pt 2009-12-05 18:37:28 +0000
56+++ lib/lp/registry/templates/structural-subscriptions-manage.pt 2010-09-16 13:11:49 +0000
57@@ -8,6 +8,20 @@
58 >
59 <body>
60 <div metal:fill-slot="main">
61+ <tal:no_permissions condition="not: view/userCanAlter|nothing">
62+ <p>
63+ You are unable to subscribe to bug reports about <span
64+ tal:replace="context/title">this item</span> as it generates
65+ a high amount of bug activity which results in more e-mails than
66+ most users can handle.
67+ </p>
68+ <p>
69+ If you really want to subscribe to <span
70+ tal:replace="context/title">this item</span> bug mail than
71+ please contact its bug supervisor.
72+ </p>
73+ </tal:no_permissions>
74+ <tal:has_permissions condition="view/userCanAlter|nothing">
75 <p>
76 You can choose to receive an e-mail every time someone reports or
77 changes a public bug associated with
78@@ -19,6 +33,7 @@
79 time.
80 </p>
81 <div metal:use-macro="context/@@launchpad_form/form" />
82+ </tal:has_permissions>
83 </div>
84 <div metal:fill-slot="side">
85 <div tal:replace="structure context/@@+portlet-malone-bugmail-filtering-faq"/>