Merge lp:~edwin-grubbs/launchpad/bug-567065-empty-branch into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-567065-empty-branch
Merge into: lp:launchpad
Diff against target: 183 lines (+80/-16)
3 files modified
lib/lp/registry/browser/productseries.py (+13/-4)
lib/lp/registry/browser/tests/productseries-setbranch-view.txt (+32/-0)
lib/lp/registry/browser/tests/productseries-views.txt (+35/-12)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-567065-empty-branch
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Abel Deuring (community) code Approve
Review via email: mp+24497@code.launchpad.net

Description of the change

Summary
-------

The "Submit Code" link in the involvement portlet on a product series
should be active after the user sets a branch for the series.

If you try to create a new branch with the same name as an existing
branch, you should get a warning.

Tests
-----

./bin/test -vv -t 'productseries-setbranch-view.txt|productseries-views.txt'

Demo and Q/A
------------

* Open http://launchpad.dev/firefox
  * Create a new series.
  * The "Submit code" link should be disabled.
  * Use "Configure series branch" link to add a new branch.
  * The "Submit code" link should now be enabled.
* Click on "Configure series branch".
  * Try to add a branch with the same name as the one you just created.
  * You should get an error message next to the form field.

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2010-04-17 00:36:18 +0000
+++ lib/lp/registry/browser/productseries.py 2010-04-30 13:56:27 +0000
@@ -182,10 +182,11 @@
182 'report_bug', 'help_translate', 'submit_code', 'register_blueprint']182 'report_bug', 'help_translate', 'submit_code', 'register_blueprint']
183183
184 def submit_code(self):184 def submit_code(self):
185 product = self.context.context.product185 view = self.context
186 product_series = view.context
186 target = canonical_url(187 target = canonical_url(
187 product, view_name='+addbranch', rootsite='code')188 product_series, view_name='+addbranch', rootsite='code')
188 enabled = product.official_codehosting189 enabled = view.official_codehosting
189 return Link(190 return Link(
190 target, 'Submit code', icon='code', enabled=enabled)191 target, 'Submit code', icon='code', enabled=enabled)
191192
@@ -1029,7 +1030,6 @@
1029 BranchType.MIRRORED, branch_name, branch_owner,1030 BranchType.MIRRORED, branch_name, branch_owner,
1030 data['repo_url'])1031 data['repo_url'])
1031 if branch is None:1032 if branch is None:
1032 self.errors_in_action = True
1033 return1033 return
10341034
1035 self.context.branch = branch1035 self.context.branch = branch
@@ -1060,6 +1060,10 @@
1060 self._setBranchExists(e.existing_branch,1060 self._setBranchExists(e.existing_branch,
1061 'branch_name')1061 'branch_name')
1062 self.errors_in_action = True1062 self.errors_in_action = True
1063 # Abort transaction. This is normally handled
1064 # by LaunchpadFormView, but we are already in
1065 # the success handler.
1066 self._abort()
1063 return1067 return
1064 self.context.branch = code_import.branch1068 self.context.branch = code_import.branch
1065 self.request.response.addInfoNotification(1069 self.request.response.addInfoNotification(
@@ -1089,6 +1093,11 @@
1089 self.context.displayname)1093 self.context.displayname)
1090 except BranchExists, e:1094 except BranchExists, e:
1091 self._setBranchExists(e.existing_branch, 'branch_name')1095 self._setBranchExists(e.existing_branch, 'branch_name')
1096 if branch is None:
1097 self.errors_in_action = True
1098 # Abort transaction. This is normally handled by
1099 # LaunchpadFormView, but we are already in the success handler.
1100 self._abort()
1092 return branch1101 return branch
10931102
10941103
10951104
=== modified file 'lib/lp/registry/browser/tests/productseries-setbranch-view.txt'
--- lib/lp/registry/browser/tests/productseries-setbranch-view.txt 2010-04-16 17:37:34 +0000
+++ lib/lp/registry/browser/tests/productseries-setbranch-view.txt 2010-04-30 13:56:27 +0000
@@ -113,6 +113,10 @@
113 ... }113 ... }
114114
115 >>> view = create_initialized_view(series, name='+setbranch', principal=product.owner, form=form)115 >>> view = create_initialized_view(series, name='+setbranch', principal=product.owner, form=form)
116 >>> print view.errors_in_action
117 False
118 >>> print view.next_url
119 http://launchpad.dev/chevy/camaro
116 >>> for error in view.errors:120 >>> for error in view.errors:
117 ... print error121 ... print error
118 >>> for notification in view.request.response.notifications:122 >>> for notification in view.request.response.notifications:
@@ -121,6 +125,26 @@
121 >>> print series.branch.name125 >>> print series.branch.name
122 camaro-branch126 camaro-branch
123127
128Using a branch name that already exists results in an error.
129
130 >>> form = {
131 ... 'field.branch_type': 'create-new',
132 ... 'field.branch_name': 'camaro-branch',
133 ... 'field.branch_owner': product.owner.name,
134 ... 'field.actions.update': 'Update',
135 ... }
136
137 >>> view = create_initialized_view(series, name='+setbranch', principal=product.owner, form=form)
138 >>> print view.errors_in_action
139 True
140 >>> print view.next_url
141 None
142 >>> for error in view.errors:
143 ... print error
144 You already have a branch for <em>Chevy</em> called <em>camaro-branch</em>.
145 >>> for notification in view.request.response.notifications:
146 ... print notification.message
147
124148
125Import a branch hosted elsewhere149Import a branch hosted elsewhere
126--------------------------------150--------------------------------
@@ -362,6 +386,10 @@
362 >>> for error in view.errors:386 >>> for error in view.errors:
363 ... print error387 ... print error
364 You already have a branch for <em>Chevy</em> called <em>chevette-branch</em>.388 You already have a branch for <em>Chevy</em> called <em>chevette-branch</em>.
389 >>> print view.errors_in_action
390 True
391 >>> print view.next_url
392 None
365393
366 >>> for notification in view.request.response.notifications:394 >>> for notification in view.request.response.notifications:
367 ... print notification.message395 ... print notification.message
@@ -381,5 +409,9 @@
381 >>> for error in view.errors:409 >>> for error in view.errors:
382 ... print error410 ... print error
383 You already have a branch for <em>Chevy</em> called <em>blazer-branch</em>.411 You already have a branch for <em>Chevy</em> called <em>blazer-branch</em>.
412 >>> print view.errors_in_action
413 True
414 >>> print view.next_url
415 None
384 >>> for notification in view.request.response.notifications:416 >>> for notification in view.request.response.notifications:
385 ... print notification.message417 ... print notification.message
386418
=== modified file 'lib/lp/registry/browser/tests/productseries-views.txt'
--- lib/lp/registry/browser/tests/productseries-views.txt 2010-04-12 15:33:19 +0000
+++ lib/lp/registry/browser/tests/productseries-views.txt 2010-04-30 13:56:27 +0000
@@ -23,23 +23,47 @@
23The ProductSeries involvement view uses the ProductSeriesInvolvedMenu when23The ProductSeries involvement view uses the ProductSeriesInvolvedMenu when
24rendering links:24rendering links:
2525
26 >>> from operator import attrgetter
27 >>> from canonical.launchpad.webapp.tales import MenuAPI
28
29 >>> login_person(product.owner)26 >>> login_person(product.owner)
30 >>> product.official_answers = True27 >>> product.official_answers = True
31 >>> product.official_blueprints = True28 >>> product.official_blueprints = True
32 >>> product.official_malone = True29 >>> product.official_malone = True
33 >>> product.official_rosetta = True30 >>> product.official_rosetta = True
34 >>> view = create_view(series, '+get-involved')31 >>> view = create_view(series, '+get-involved')
35 >>> menuapi = MenuAPI(view)32
36 >>> for link in sorted(33 # official_answers is always false for product series.
37 ... menuapi.navigation.values(), key=attrgetter('sort_key')):34 >>> print view.official_answers
38 ... print link.url35 False
39 http://bugs.launchpad.dev/app/simple/+filebug36 >>> print view.official_blueprints
40 http://translations.launchpad.dev/app/simple37 True
41 http://code.launchpad.dev/app/+addbranch38 >>> print view.official_malone
42 http://blueprints.launchpad.dev/app/simple/+addspec39 True
40 >>> print view.official_rosetta
41 True
42 >>> print view.official_codehosting
43 False
44 >>> for link in view.enabled_links:
45 ... print link.url
46 http://bugs.launchpad.dev/app/simple/+filebug
47 http://translations.launchpad.dev/app/simple
48 http://blueprints.launchpad.dev/app/simple/+addspec
49 >>> for link in view.visible_disabled_links:
50 ... print link.url
51 http://code.launchpad.dev/app/simple/+addbranch
52
53Setting a branch for the series should enable the +addbranch link.
54
55 >>> series.branch = factory.makeBranch()
56 >>> view = create_view(series, '+get-involved')
57 >>> print view.official_codehosting
58 True
59 >>> for link in view.enabled_links:
60 ... print link.url
61 http://bugs.launchpad.dev/app/simple/+filebug
62 http://translations.launchpad.dev/app/simple
63 http://code.launchpad.dev/app/simple/+addbranch
64 http://blueprints.launchpad.dev/app/simple/+addspec
65 >>> for link in view.visible_disabled_links:
66 ... print link.url
4367
4468
45ProductSeries view69ProductSeries view
@@ -360,7 +384,6 @@
360The delete action will not delete a series that is the active focus of384The delete action will not delete a series that is the active focus of
361development.385development.
362386
363 >>> transaction.commit()
364 >>> form = {387 >>> form = {
365 ... 'field.actions.delete': 'Delete this Series',388 ... 'field.actions.delete': 'Delete this Series',
366 ... }389 ... }