Merge lp://staging/~intellectronica/launchpad/disable-ubuntu-filebug into lp://staging/launchpad

Proposed by Eleanor Berger
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~intellectronica/launchpad/disable-ubuntu-filebug
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~intellectronica/launchpad/disable-ubuntu-filebug
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+11370@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Eleanor Berger (intellectronica) wrote :

This branch adds the possibility to disable +filebug for Ubuntu. The option is configurable, and a new test is added where the configuration flag is set to demonstrate the expected behaviour.

Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/config/schema-lazr.conf'
2--- lib/canonical/config/schema-lazr.conf 2009-08-31 16:31:24 +0000
3+++ lib/canonical/config/schema-lazr.conf 2009-09-08 15:16:33 +0000
4@@ -1346,6 +1346,14 @@
5 comments_list_max_length: 100
6 comments_list_truncate_to: 80
7
8+# Should +filebug be disabled for Ubuntu ?
9+ubuntu_disable_filebug: false
10+
11+# Redirect to this URL when users try to file a bug on Ubuntu without
12+# using apport.
13+ubuntu_bug_filing_url: https://help.ubuntu.com/community/ReportingBugs
14+
15+
16 [mpcreationjobs]
17 # The database user which will be used by this process.
18 # datatype: string
19
20=== modified file 'lib/lp/bugs/browser/bugtarget.py'
21--- lib/lp/bugs/browser/bugtarget.py 2009-09-07 12:49:43 +0000
22+++ lib/lp/bugs/browser/bugtarget.py 2009-09-08 15:16:33 +0000
23@@ -37,6 +37,7 @@
24 from zope.schema.vocabulary import SimpleVocabulary
25
26 from canonical.cachedproperty import cachedproperty
27+from canonical.config import config
28 from lp.bugs.browser.bugtask import BugTaskSearchListingView
29 from canonical.launchpad.browser.feeds import (
30 BugFeedLink, BugTargetLatestBugsFeedLink, FeedsMixin,
31@@ -264,6 +265,15 @@
32
33 def initialize(self):
34 LaunchpadFormView.initialize(self)
35+
36+ if (config.malone.ubuntu_disable_filebug and
37+ self.targetIsUbuntu() and
38+ self.extra_data_token is None and
39+ not self.no_ubuntu_redirect):
40+ # The user is trying to file a new Ubuntu bug via the web
41+ # interface and without using apport. Redirect to a page
42+ # explaining the preferred bug-filing procedure.
43+ self.request.response.redirect(config.malone.ubuntu_bug_filing_url)
44 if self.extra_data_token is not None:
45 # self.extra_data has been initialized in publishTraverse().
46 if self.extra_data.initial_summary:
47@@ -321,6 +331,22 @@
48 def contextIsProject(self):
49 return IProject.providedBy(self.context)
50
51+ def targetIsUbuntu(self):
52+ ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
53+ return (self.context == ubuntu or
54+ (IMaloneApplication.providedBy(self.context) and
55+ self.request.form.get('field.bugtarget.distribution') ==
56+ ubuntu.name) or
57+ (IDistributionSourcePackage.providedBy(self.context) and
58+ self.context.distribution == ubuntu))
59+
60+ @property
61+ def no_ubuntu_redirect(self):
62+ return (
63+ self.request.form.get('no-redirect') is not None or
64+ [key for key in self.request.form.keys()
65+ if 'field.actions' in key] != [])
66+
67 def getPackageNameFieldCSSClass(self):
68 """Return the CSS class for the packagename field."""
69 if self.widget_errors.get("packagename"):
70
71=== added file 'lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt'
72--- lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt 1970-01-01 00:00:00 +0000
73+++ lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt 2009-09-08 15:16:33 +0000
74@@ -0,0 +1,54 @@
75+Ubuntu and +filebug
76+-------------------
77+
78+When so configured, Launchpad blocks users from filing Ubuntu bugs directly
79+from the web interface.
80+
81+We set the `ubuntu_disable_filebug` flag to true, and set the URL to redirect
82+to to a local page (the default configuration is for a page on the Ubuntu
83+wiki).
84+
85+ >>> from canonical.config import config
86+ >>> config.push('malone', '''
87+ ... [malone]
88+ ... ubuntu_disable_filebug: true
89+ ... ubuntu_bug_filing_url: http://launchpad.dev/+tour
90+ ... ''')
91+
92+Tring to navigate to the 'report a bug' page, redirects us to the alternative
93+page.
94+
95+ >>> user_browser.open('http://launchpad.dev/ubuntu')
96+ >>> user_browser.getLink('Report a bug').click()
97+ >>> print user_browser.url
98+ http://launchpad.dev/+tour/index
99+
100+We can override this behaviour by adding the `no-redirect` query parameter.
101+
102+ >>> user_browser.open(
103+ ... 'http://bugs.launchpad.dev/ubuntu/+filebug?no-redirect')
104+ >>> print user_browser.title
105+ Report a bug about Ubuntu Linux
106+
107+Filing bugs with Apport also allows us to get to the bug filing interface.
108+
109+ >>> import os.path
110+ >>> testfiles = os.path.join(config.root, 'lib/lp/bugs/tests/testfiles')
111+ >>> extra_filebug_data = open(
112+ ... os.path.join(testfiles, 'extra_filebug_data.msg'))
113+ >>> anon_browser.open('http://launchpad.dev/+storeblob')
114+ >>> anon_browser.getControl(name='field.blob').add_file( # Don't change!
115+ ... extra_filebug_data, 'not/important', 'not.important')
116+ >>> anon_browser.getControl(name='FORM_SUBMIT').click() # Don't change!
117+ >>> blob_token = anon_browser.headers['X-Launchpad-Blob-Token']
118+ >>> filebug_url = (
119+ ... 'http://launchpad.dev/ubuntu/+source/mozilla-firefox/+filebug/'
120+ ... '%s' % blob_token)
121+ >>> user_browser.open(
122+ ... 'http://launchpad.dev/ubuntu/+source/mozilla-firefox/+filebug/%s'
123+ ... % blob_token)
124+ >>> print user_browser.url
125+ http://launchpad.dev/ubuntu/+source/mozilla-firefox/+filebug/...
126+
127+ >>> _ = config.pop('malone')
128+