Merge lp:~jmglogow/launchpad/bugfix_420515 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jmglogow/launchpad/bugfix_420515
Merge into: lp:launchpad
Diff against target: 31 lines (+4/-3)
1 file modified
lib/lp/registry/browser/distroseries.py (+4/-3)
To merge this branch: bzr merge lp:~jmglogow/launchpad/bugfix_420515
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+14870@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Jan.

We normally wait for the developer to propose a merge, but I know your branch fixes the issue and would like to merge it.

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

Hi Jan.

I agree that your branch fixes the most common case, but not all. The field you fixed is in a mixin used by two views. The edit view and the admin view. You could update the admin view to pass the value to createStatusField, but I have an alternate proposal.

Since the status field is required, and the distroseries (eg `context`) is known to the createStatusField method, we do not need to pass the value.

This branch also needs a test. If we had written one years ago we would have known the form was bad.

I think the fix looks something like this:

=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2009-11-13 21:55:42 +0000
+++ lib/lp/registry/browser/distroseries.py 2009-11-14 18:26:07 +0000
@@ -272,6 +272,7 @@
         return form.Fields(
             Choice(__name__='status',
                    title=_('Status'),
+ default=self.context.status,
                    vocabulary=status_vocabulary,
                    description=_("Select the distroseries status."),
                    required=True))

=== modified file 'lib/lp/registry/browser/tests/distroseries-views.txt'
--- lib/lp/registry/browser/tests/distroseries-views.txt 2009-09-25 18:15:48 +0000
+++ lib/lp/registry/browser/tests/distroseries-views.txt 2009-11-14 18:23:13 +0000
@@ -186,6 +186,9 @@
     >>> [field.__name__ for field in view.form_fields]
     ['displayname', 'title', 'summary', 'description', 'status']

+ >>> print view.widgets.get('status')._getFormValue()
+ Active Development

I have a branch that revises your changes. If you merge it in I will land your branch
    bzr merge lp:~sinzui/launchpad/bugfix_420515

Thanks a lot for finding a fix for the issue.

review: Needs Fixing (code)
Revision history for this message
Curtis Hovey (sinzui) wrote :

I landed the change with the test I added.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/distroseries.py'
2--- lib/lp/registry/browser/distroseries.py 2009-11-13 21:55:42 +0000
3+++ lib/lp/registry/browser/distroseries.py 2009-11-14 18:30:43 +0000
4@@ -245,7 +245,7 @@
5 class DistroSeriesStatusMixin:
6 """A mixin that provides status field support."""
7
8- def createStatusField(self):
9+ def createStatusField(self, default=None):
10 """Create the 'status' field.
11
12 Create the status vocabulary according the current distroseries
13@@ -272,6 +272,7 @@
14 return form.Fields(
15 Choice(__name__='status',
16 title=_('Status'),
17+ default=default,
18 vocabulary=status_vocabulary,
19 description=_("Select the distroseries status."),
20 required=True))
21@@ -369,8 +370,8 @@
22 LaunchpadEditFormView.setUpFields(self)
23 if not self.context.distribution.full_functionality:
24 # This is an IDerivativeDistribution which may set its status.
25- self.form_fields = (
26- self.form_fields + self.createStatusField())
27+ self.form_fields = (self.form_fields +
28+ self.createStatusField(self.context.status))
29
30 @action("Change")
31 def change_action(self, action, data):