Merge lp:~gmb/launchpad/ubuntu-filebug-dupefinder-bug-497096 into lp:launchpad/db-devel

Proposed by Graham Binns
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~gmb/launchpad/ubuntu-filebug-dupefinder-bug-497096
Merge into: lp:launchpad/db-devel
Diff against target: 112 lines (+48/-25)
2 files modified
lib/lp/bugs/browser/bugtarget.py (+34/-25)
lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt (+14/-0)
To merge this branch: bzr merge lp:~gmb/launchpad/ubuntu-filebug-dupefinder-bug-497096
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Данило Шеган (community) release-critical Approve
Gavin Panella code Pending
Review via email: mp+16230@code.launchpad.net

Commit message

The +filebug inline dupe finder will now work for the Ubuntu +filebug form.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

This branch fixes bug 497096 by moving the Ubuntu +filebug redirect code into FileBugGuidedView, which is where it actually gets used. This means that sundry +filebug views (+filebug-inline-form, +filebug-show-similar and so on) shouldn't redirect, which means that the inline dupe finder will now work.

You can QA this on lp.dev by setting ubuntu_disable_filebug to True in configs/development/launchpad-lazr.conf and hitting ubuntu/+filebug with ?no-redirect=1 in the query string. The dupe finder should Just Work.

Revision history for this message
Данило Шеган (danilo) wrote :

Mostly moved code to the appropriate view. Do get another review, and please confirm there's a test that redirect keeps working where it should. Also, don't forget the QA before landing, because there won't be enough time to QA after this lands.

review: Approve (release-critical)
Revision history for this message
Gavin Panella (allenap) wrote :

<allenap> gmb: Should lines 20 to 33 also be moving?
<gmb> allenap: Eh... Hmm. Well, it passes the tests ;). But no, probably not. I'll move those back.
<gmb> allenap: Although that gets a bit knotty then...
<gmb> allenap: No, I'll move it back, because otherwise it will have nasty effects on the other +filebug views when extra data get passed.

review: Approve
Revision history for this message
Graham Binns (gmb) wrote :
Download full text (4.2 KiB)

I had to do a slight refactor to make the fix that Gavin and I agreed on:

=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py 2009-12-16 08:13:19 +0000
+++ lib/lp/bugs/browser/bugtarget.py 2009-12-16 09:38:58 +0000
@@ -270,6 +270,44 @@
         LaunchpadFormView.__init__(self, context, request)
         self.extra_data = FileBugData()

+ def initialize(self):
+ LaunchpadFormView.initialize(self)
+ if (not self.redirect_ubuntu_filebug and
+ self.extra_data_token is not None):
+ # self.extra_data has been initialized in publishTraverse().
+ if self.extra_data.initial_summary:
+ self.widgets['title'].setRenderedValue(
+ self.extra_data.initial_summary)
+ if self.extra_data.initial_tags:
+ self.widgets['tags'].setRenderedValue(
+ self.extra_data.initial_tags)
+ # XXX: Bjorn Tillenius 2006-01-15:
+ # We should include more details of what will be added
+ # to the bug report.
+ self.request.response.addNotification(
+ 'Extra debug information will be added to the bug report'
+ ' automatically.')
+
+ @cachedproperty
+ def redirect_ubuntu_filebug(self):
+ if IDistribution.providedBy(self.context):
+ bug_supervisor = self.context.bug_supervisor
+ elif (IDistributionSourcePackage.providedBy(self.context) or
+ ISourcePackage.providedBy(self.context)):
+ bug_supervisor = self.context.distribution.bug_supervisor
+
+ # Work out whether the redirect should be overidden.
+ do_not_redirect = (
+ self.request.form.get('no-redirect') is not None or
+ [key for key in self.request.form.keys()
+ if 'field.actions' in key] != [] or
+ self.user.inTeam(bug_supervisor))
+
+ return (
+ config.malone.ubuntu_disable_filebug and
+ self.targetIsUbuntu() and
+ self.extra_data_token is None and
+ not do_not_redirect)

     @property
     def field_names(self):
@@ -928,45 +966,13 @@
     show_summary_in_results = True

     def initialize(self):
- LaunchpadFormView.initialize(self)
-
- if (config.malone.ubuntu_disable_filebug and
- self.targetIsUbuntu() and
- self.extra_data_token is None and
- not self.no_ubuntu_redirect):
+ FilebugShowSimilarBugsView.initialize(self)
+ if self.redirect_ubuntu_filebug:
             # The user is trying to file a new Ubuntu bug via the web
             # interface and without using apport. Redirect to a page
             # explaining the preferred bug-filing procedure.
             self.request.response.redirect(
                 config.malone.ubuntu_bug_filing_url)
- if self.extra_data_token is not None:
- # self.extra_data has been initialized in publishTraverse().
- if self.extra_data.initial_summary:
- self.widgets['title'].setRenderedValue(
- self.extra_data.initial_summary)
- if self.extra_dat...

Read more...

Revision history for this message
Gavin Panella (allenap) wrote :

 review approve
 merge approve

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

FTR, Gavin has approved the incremental diff; he's managed to break this merge proposal so that he can't add anything to it. Well done, Gavin.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtarget.py'
2--- lib/lp/bugs/browser/bugtarget.py 2009-12-11 10:58:46 +0000
3+++ lib/lp/bugs/browser/bugtarget.py 2009-12-16 10:34:17 +0000
4@@ -272,17 +272,8 @@
5
6 def initialize(self):
7 LaunchpadFormView.initialize(self)
8-
9- if (config.malone.ubuntu_disable_filebug and
10- self.targetIsUbuntu() and
11- self.extra_data_token is None and
12- not self.no_ubuntu_redirect):
13- # The user is trying to file a new Ubuntu bug via the web
14- # interface and without using apport. Redirect to a page
15- # explaining the preferred bug-filing procedure.
16- self.request.response.redirect(
17- config.malone.ubuntu_bug_filing_url)
18- if self.extra_data_token is not None:
19+ if (not self.redirect_ubuntu_filebug and
20+ self.extra_data_token is not None):
21 # self.extra_data has been initialized in publishTraverse().
22 if self.extra_data.initial_summary:
23 self.widgets['title'].setRenderedValue(
24@@ -297,6 +288,29 @@
25 'Extra debug information will be added to the bug report'
26 ' automatically.')
27
28+ @cachedproperty
29+ def redirect_ubuntu_filebug(self):
30+ if IDistribution.providedBy(self.context):
31+ bug_supervisor = self.context.bug_supervisor
32+ elif (IDistributionSourcePackage.providedBy(self.context) or
33+ ISourcePackage.providedBy(self.context)):
34+ bug_supervisor = self.context.distribution.bug_supervisor
35+ else:
36+ bug_supervisor = None
37+
38+ # Work out whether the redirect should be overidden.
39+ do_not_redirect = (
40+ self.request.form.get('no-redirect') is not None or
41+ [key for key in self.request.form.keys()
42+ if 'field.actions' in key] != [] or
43+ self.user.inTeam(bug_supervisor))
44+
45+ return (
46+ config.malone.ubuntu_disable_filebug and
47+ self.targetIsUbuntu() and
48+ self.extra_data_token is None and
49+ not do_not_redirect)
50+
51 @property
52 def field_names(self):
53 """Return the list of field names to display."""
54@@ -346,20 +360,6 @@
55 self.request.form.get('field.bugtarget.distribution') ==
56 ubuntu.name))
57
58- @property
59- def no_ubuntu_redirect(self):
60- if IDistribution.providedBy(self.context):
61- bug_supervisor = self.context.bug_supervisor
62- elif (IDistributionSourcePackage.providedBy(self.context) or
63- ISourcePackage.providedBy(self.context)):
64- bug_supervisor = self.context.distribution.bug_supervisor
65-
66- return (
67- self.request.form.get('no-redirect') is not None or
68- [key for key in self.request.form.keys()
69- if 'field.actions' in key] != [] or
70- self.user.inTeam(bug_supervisor))
71-
72 def getPackageNameFieldCSSClass(self):
73 """Return the CSS class for the packagename field."""
74 if self.widget_errors.get("packagename"):
75@@ -967,6 +967,15 @@
76 focused_element_id = 'field.title'
77 show_summary_in_results = True
78
79+ def initialize(self):
80+ FilebugShowSimilarBugsView.initialize(self)
81+ if self.redirect_ubuntu_filebug:
82+ # The user is trying to file a new Ubuntu bug via the web
83+ # interface and without using apport. Redirect to a page
84+ # explaining the preferred bug-filing procedure.
85+ self.request.response.redirect(
86+ config.malone.ubuntu_bug_filing_url)
87+
88 @safe_action
89 @action("Continue", name="search", validator="validate_search")
90 def search_action(self, action, data):
91
92=== modified file 'lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt'
93--- lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt 2009-10-20 13:26:19 +0000
94+++ lib/lp/bugs/stories/guided-filebug/xx-ubuntu-filebug.txt 2009-12-16 10:34:17 +0000
95@@ -81,3 +81,17 @@
96
97 >>> _ = config.pop('malone')
98
99+The inline filebug form never gets redirected.
100+
101+ >>> user_browser.open(
102+ ... 'http://bugs.launchpad.dev/ubuntu/+filebug-inline-form')
103+ >>> print user_browser.url
104+ http://bugs.launchpad.dev/ubuntu/+filebug-inline-form
105+
106+Neither does the show-similar-bugs view.
107+
108+ >>> user_browser.open(
109+ ... 'http://bugs.launchpad.dev/ubuntu/'
110+ ... '+filebug-show-similar?title=testing')
111+ >>> print user_browser.url
112+ http://bugs.launchpad.dev/ubuntu/+filebug-show-similar?title=testing

Subscribers

People subscribed via source and target branches

to status/vote changes: