Code review comment for lp:~gmb/launchpad/ubuntu-filebug-dupefinder-bug-497096

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

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_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.')
-
- @property
- def no_ubuntu_redirect(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
-
- return (
- 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))

     @safe_action
     @action("Continue", name="search", validator="validate_search")

« Back to merge proposal