Merge lp:~stevenk/launchpad/no-private-registrant-setbranch into lp:launchpad
- no-private-registrant-setbranch
- Merge into devel
Proposed by
Steve Kowalik
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 16100 | ||||
Proposed branch: | lp:~stevenk/launchpad/no-private-registrant-setbranch | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
431 lines (+77/-82) 2 files modified
lib/lp/registry/browser/productseries.py (+27/-38) lib/lp/registry/browser/tests/productseries-setbranch-view.txt (+50/-44) |
||||
To merge this branch: | bzr merge lp:~stevenk/launchpad/no-private-registrant-setbranch | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+128173@code.launchpad.net |
Commit message
No longer set the registrant of a new code import on ProductSeries:
Description of the change
No longer set the registrant of a new code import on ProductSeries:
I have switched productseries-
I have re-factored part of and cleaned up productseries to get this branch to be net-negative.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/registry/browser/productseries.py' |
2 | --- lib/lp/registry/browser/productseries.py 2012-07-03 08:04:35 +0000 |
3 | +++ lib/lp/registry/browser/productseries.py 2012-10-05 07:32:23 +0000 |
4 | @@ -1,4 +1,4 @@ |
5 | -# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
6 | +# Copyright 2009-2012 Canonical Ltd. This software is licensed under the |
7 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | |
9 | """View classes for `IProductSeries`.""" |
10 | @@ -260,8 +260,7 @@ |
11 | configured = True |
12 | else: |
13 | configured = False |
14 | - return [dict(link=set_branch, |
15 | - configured=configured)] |
16 | + return [dict(link=set_branch, configured=configured)] |
17 | |
18 | |
19 | class ProductSeriesOverviewMenu( |
20 | @@ -292,8 +291,8 @@ |
21 | text = 'Configure bug tracker' |
22 | summary = 'Specify where bugs are tracked for this project' |
23 | return Link( |
24 | - canonical_url(self.context.product, |
25 | - view_name='+configure-bugtracker'), |
26 | + canonical_url( |
27 | + self.context.product, view_name='+configure-bugtracker'), |
28 | text, summary, icon='edit') |
29 | |
30 | @enabled_with_permission('launchpad.Edit') |
31 | @@ -317,17 +316,21 @@ |
32 | summary = 'Someone with permission to set goals this series' |
33 | return Link('+driver', text, summary, icon='edit') |
34 | |
35 | + def _fetch_branch_link(self): |
36 | + if self.context.branch is None: |
37 | + text = 'Link to branch' |
38 | + icon = 'add' |
39 | + summary = 'Set the branch for this series' |
40 | + else: |
41 | + text = "Change branch" |
42 | + icon = 'edit' |
43 | + summary = 'Change the branch for this series' |
44 | + return (text, icon, summary) |
45 | + |
46 | @enabled_with_permission('launchpad.Edit') |
47 | def link_branch(self): |
48 | """Return a link to set the bazaar branch for this series.""" |
49 | - if self.context.branch is None: |
50 | - text = 'Link to branch' |
51 | - icon = 'add' |
52 | - summary = 'Set the branch for this series' |
53 | - else: |
54 | - text = "Change branch" |
55 | - icon = 'edit' |
56 | - summary = 'Change the branch for this series' |
57 | + text, icon, summary = self._fetch_branch_link() |
58 | return Link('+linkbranch', text, summary, icon=icon) |
59 | |
60 | @enabled_with_permission('launchpad.Edit') |
61 | @@ -335,14 +338,7 @@ |
62 | """Return a link to set the bazaar branch for this series.""" |
63 | # Once +setbranch has been beta tested thoroughly, it should |
64 | # replace the +linkbranch page. |
65 | - if self.context.branch is None: |
66 | - text = 'Link to branch' |
67 | - icon = 'add' |
68 | - summary = 'Set the branch for this series' |
69 | - else: |
70 | - text = "Change branch" |
71 | - icon = 'edit' |
72 | - summary = 'Change the branch for this series' |
73 | + text, icon, summary = self._fetch_branch_link() |
74 | return Link('+setbranch', text, summary, icon=icon) |
75 | |
76 | @enabled_with_permission('launchpad.AnyPerson') |
77 | @@ -424,11 +420,8 @@ |
78 | if branch.product != product: |
79 | return structured( |
80 | '<a href="%s">%s</a> is not a branch of <a href="%s">%s</a>.', |
81 | - canonical_url(branch), |
82 | - branch.unique_name, |
83 | - canonical_url(product), |
84 | + canonical_url(branch), branch.unique_name, canonical_url(product), |
85 | product.displayname) |
86 | - return None |
87 | |
88 | |
89 | class ProductSeriesView(LaunchpadView, MilestoneOverlayMixin): |
90 | @@ -1084,7 +1077,8 @@ |
91 | rcs_item = RevisionControlSystems.items[rcs_type.name] |
92 | try: |
93 | code_import = getUtility(ICodeImportSet).new( |
94 | - registrant=branch_owner, |
95 | + owner=branch_owner, |
96 | + registrant=self.user, |
97 | target=IBranchTarget(self.context.product), |
98 | branch_name=branch_name, |
99 | rcs_type=rcs_item, |
100 | @@ -1092,8 +1086,8 @@ |
101 | cvs_root=cvs_root, |
102 | cvs_module=cvs_module) |
103 | except BranchExists as e: |
104 | - self._setBranchExists(e.existing_branch, |
105 | - 'branch_name') |
106 | + self._setBranchExists( |
107 | + e.existing_branch, 'branch_name') |
108 | self.errors_in_action = True |
109 | # Abort transaction. This is normally handled |
110 | # by LaunchpadFormView, but we are already in |
111 | @@ -1102,8 +1096,7 @@ |
112 | return |
113 | self.context.branch = code_import.branch |
114 | self.request.response.addInfoNotification( |
115 | - 'Code import created and branch linked to the ' |
116 | - 'series.') |
117 | + 'Code import created and branch linked to the series.') |
118 | else: |
119 | raise UnexpectedFormData(branch_type) |
120 | |
121 | @@ -1115,10 +1108,9 @@ |
122 | branch = None |
123 | try: |
124 | namespace = self.target.getNamespace(branch_owner) |
125 | - branch = namespace.createBranch(branch_type=BranchType.HOSTED, |
126 | - name=branch_name, |
127 | - registrant=self.user, |
128 | - url=repo_url) |
129 | + branch = namespace.createBranch( |
130 | + branch_type=BranchType.HOSTED, name=branch_name, |
131 | + registrant=self.user, url=repo_url) |
132 | except BranchCreationForbidden: |
133 | self.addError( |
134 | "You are not allowed to create branches in %s." % |
135 | @@ -1187,10 +1179,7 @@ |
136 | return 'Administer %s %s series' % ( |
137 | self.context.product.displayname, self.context.name) |
138 | |
139 | - @property |
140 | - def page_title(self): |
141 | - """The page title.""" |
142 | - return self.label |
143 | + page_title = label |
144 | |
145 | @property |
146 | def cancel_url(self): |
147 | |
148 | === modified file 'lib/lp/registry/browser/tests/productseries-setbranch-view.txt' |
149 | --- lib/lp/registry/browser/tests/productseries-setbranch-view.txt 2012-04-10 14:01:17 +0000 |
150 | +++ lib/lp/registry/browser/tests/productseries-setbranch-view.txt 2012-10-05 07:32:23 +0000 |
151 | @@ -7,12 +7,16 @@ |
152 | that exists externally in a variety of version control systems. |
153 | |
154 | >>> from lp.testing.pages import find_tag_by_id |
155 | - >>> product = factory.makeProduct(name="chevy") |
156 | + >>> driver = factory.makePerson() |
157 | + >>> from lp.registry.enums import TeamMembershipPolicy |
158 | + >>> team = factory.makeTeam( |
159 | + ... owner=driver, membership_policy=TeamMembershipPolicy.MODERATED) |
160 | + >>> product = factory.makeProduct(name="chevy", owner=team) |
161 | >>> series = factory.makeProductSeries(name="impala", product=product) |
162 | >>> transaction.commit() |
163 | - >>> ignored = login_person(product.owner) |
164 | - >>> view = create_initialized_view(series, name='+setbranch', |
165 | - ... principal=product.owner) |
166 | + >>> ignored = login_person(driver) |
167 | + >>> view = create_initialized_view( |
168 | + ... series, name='+setbranch', principal=driver) |
169 | >>> content = find_tag_by_id(view.render(), 'maincontent') |
170 | >>> print content |
171 | <div... |
172 | @@ -38,8 +42,8 @@ |
173 | ... 'field.branch_type': 'link-lp-bzr', |
174 | ... 'field.actions.update': 'Update', |
175 | ... } |
176 | - >>> view = create_initialized_view(series, name='+setbranch', |
177 | - ... principal=product.owner, form=form) |
178 | + >>> view = create_initialized_view( |
179 | + ... series, name='+setbranch', principal=driver, form=form) |
180 | >>> for error in view.errors: |
181 | ... print error |
182 | The branch location must be set. |
183 | @@ -52,8 +56,8 @@ |
184 | ... 'field.branch_location': 'foo', |
185 | ... 'field.actions.update': 'Update', |
186 | ... } |
187 | - >>> view = create_initialized_view(series, name='+setbranch', |
188 | - ... principal=product.owner, form=form) |
189 | + >>> view = create_initialized_view( |
190 | + ... series, name='+setbranch', principal=driver, form=form) |
191 | >>> for error in view.errors: |
192 | ... print error |
193 | ('Invalid value', InvalidValue("token 'foo' not found in vocabulary")) |
194 | @@ -62,15 +66,15 @@ |
195 | |
196 | >>> series.branch is None |
197 | True |
198 | - >>> branch = factory.makeBranch(name='impala-branch', |
199 | - ... owner=product.owner, product=product) |
200 | + >>> branch = factory.makeBranch( |
201 | + ... name='impala-branch', owner=driver, product=product) |
202 | >>> form = { |
203 | ... 'field.branch_type': 'link-lp-bzr', |
204 | ... 'field.branch_location': branch.unique_name, |
205 | ... 'field.actions.update': 'Update', |
206 | ... } |
207 | - >>> view = create_initialized_view(series, name='+setbranch', |
208 | - ... principal=product.owner, form=form) |
209 | + >>> view = create_initialized_view( |
210 | + ... series, name='+setbranch', principal=driver, form=form) |
211 | >>> for error in view.errors: |
212 | ... print error |
213 | >>> for notification in view.request.response.notifications: |
214 | @@ -83,8 +87,8 @@ |
215 | Revisiting the +setbranch page when the branch is already set will |
216 | show the branch location pre-populated with the existing value. |
217 | |
218 | - >>> view = create_initialized_view(series, name='+setbranch', |
219 | - ... principal=product.owner, form=form) |
220 | + >>> view = create_initialized_view( |
221 | + ... series, name='+setbranch', principal=driver, form=form) |
222 | >>> print view.widgets.get('branch_location')._getFormValue().unique_name |
223 | ~person.../chevy/impala-branch |
224 | |
225 | @@ -105,7 +109,7 @@ |
226 | ... 'field.actions.update': 'Update', |
227 | ... } |
228 | >>> view = create_initialized_view( |
229 | - ... series, name='+setbranch', principal=product.owner, form=form) |
230 | + ... series, name='+setbranch', principal=driver, form=form) |
231 | >>> for notification in view.request.response.notifications: |
232 | ... print notification.message |
233 | >>> for error in view.errors: |
234 | @@ -121,12 +125,12 @@ |
235 | ... 'field.branch_type': 'import-external', |
236 | ... 'field.rcs_type': 'BZR', |
237 | ... 'field.branch_name': 'blazer-branch', |
238 | - ... 'field.branch_owner': product.owner.name, |
239 | + ... 'field.branch_owner': team.name, |
240 | ... 'field.repo_url': 'bzr+ssh://bzr.com/foo', |
241 | ... 'field.actions.update': 'Update', |
242 | ... } |
243 | >>> view = create_initialized_view( |
244 | - ... series, name='+setbranch', principal=product.owner, form=form) |
245 | + ... series, name='+setbranch', principal=driver, form=form) |
246 | >>> for notification in view.request.response.notifications: |
247 | ... print notification.message |
248 | >>> for error in view.errors: |
249 | @@ -141,12 +145,12 @@ |
250 | ... 'field.branch_type': 'import-external', |
251 | ... 'field.rcs_type': 'BZR', |
252 | ... 'field.branch_name': 'blazer-branch', |
253 | - ... 'field.branch_owner': product.owner.name, |
254 | + ... 'field.branch_owner': team.name, |
255 | ... 'field.repo_url': 'http://bzr.com/foo', |
256 | ... 'field.actions.update': 'Update', |
257 | ... } |
258 | >>> view = create_initialized_view( |
259 | - ... series, name='+setbranch', principal=product.owner, form=form) |
260 | + ... series, name='+setbranch', principal=driver, form=form) |
261 | >>> transaction.commit() |
262 | >>> for error in view.errors: |
263 | ... print error |
264 | @@ -155,6 +159,8 @@ |
265 | Code import created and branch linked to the series. |
266 | >>> print series.branch.name |
267 | blazer-branch |
268 | + >>> series.branch.registrant.name == driver.name |
269 | + True |
270 | |
271 | Git branches cannnot use svn. |
272 | |
273 | @@ -162,12 +168,12 @@ |
274 | ... 'field.branch_type': 'import-external', |
275 | ... 'field.rcs_type': 'GIT', |
276 | ... 'field.branch_name': 'chevette-branch', |
277 | - ... 'field.branch_owner': product.owner.name, |
278 | + ... 'field.branch_owner': team.name, |
279 | ... 'field.repo_url': 'svn://svn.com/chevette', |
280 | ... 'field.actions.update': 'Update', |
281 | ... } |
282 | >>> view = create_initialized_view( |
283 | - ... series, name='+setbranch', principal=product.owner, form=form) |
284 | + ... series, name='+setbranch', principal=driver, form=form) |
285 | >>> for notification in view.request.response.notifications: |
286 | ... print notification.message |
287 | >>> for error in view.errors: |
288 | @@ -183,12 +189,12 @@ |
289 | ... 'field.branch_type': 'import-external', |
290 | ... 'field.rcs_type': 'GIT', |
291 | ... 'field.branch_name': 'chevette-branch', |
292 | - ... 'field.branch_owner': product.owner.name, |
293 | + ... 'field.branch_owner': team.name, |
294 | ... 'field.repo_url': 'git://github.com/chevette', |
295 | ... 'field.actions.update': 'Update', |
296 | ... } |
297 | >>> view = create_initialized_view( |
298 | - ... series, name='+setbranch', principal=product.owner, form=form) |
299 | + ... series, name='+setbranch', principal=driver, form=form) |
300 | >>> transaction.commit() |
301 | >>> for error in view.errors: |
302 | ... print error |
303 | @@ -204,12 +210,12 @@ |
304 | ... 'field.branch_type': 'import-external', |
305 | ... 'field.rcs_type': 'BZR_SVN', |
306 | ... 'field.branch_name': 'suburban-branch', |
307 | - ... 'field.branch_owner': product.owner.name, |
308 | + ... 'field.branch_owner': team.name, |
309 | ... 'field.repo_url': 'git://github.com/suburban', |
310 | ... 'field.actions.update': 'Update', |
311 | ... } |
312 | >>> view = create_initialized_view( |
313 | - ... series, name='+setbranch', principal=product.owner, form=form) |
314 | + ... series, name='+setbranch', principal=driver, form=form) |
315 | >>> for notification in view.request.response.notifications: |
316 | ... print notification.message |
317 | >>> for error in view.errors: |
318 | @@ -225,12 +231,12 @@ |
319 | ... 'field.branch_type': 'import-external', |
320 | ... 'field.rcs_type': 'BZR_SVN', |
321 | ... 'field.branch_name': 'suburban-branch', |
322 | - ... 'field.branch_owner': product.owner.name, |
323 | + ... 'field.branch_owner': team.name, |
324 | ... 'field.repo_url': 'svn://svn.com/suburban', |
325 | ... 'field.actions.update': 'Update', |
326 | ... } |
327 | >>> view = create_initialized_view( |
328 | - ... series, name='+setbranch', principal=product.owner, form=form) |
329 | + ... series, name='+setbranch', principal=driver, form=form) |
330 | >>> for error in view.errors: |
331 | ... print error |
332 | >>> for notification in view.request.response.notifications: |
333 | @@ -247,12 +253,12 @@ |
334 | ... 'field.branch_type': 'import-external', |
335 | ... 'field.rcs_type': 'HG', |
336 | ... 'field.branch_name': 'malibu-branch', |
337 | - ... 'field.branch_owner': product.owner.name, |
338 | + ... 'field.branch_owner': team.name, |
339 | ... 'field.repo_url': 'https://mercurial.com/branch', |
340 | ... 'field.actions.update': 'Update', |
341 | ... } |
342 | >>> view = create_initialized_view( |
343 | - ... series, name='+setbranch', principal=product.owner, form=form) |
344 | + ... series, name='+setbranch', principal=driver, form=form) |
345 | >>> for error in view.errors: |
346 | ... print error |
347 | >>> for notification in view.request.response.notifications: |
348 | @@ -270,12 +276,12 @@ |
349 | ... 'field.branch_type': 'import-external', |
350 | ... 'field.rcs_type': 'CVS', |
351 | ... 'field.branch_name': 'corvair-branch', |
352 | - ... 'field.branch_owner': product.owner.name, |
353 | + ... 'field.branch_owner': team.name, |
354 | ... 'field.repo_url': 'https://cvs.com/branch', |
355 | ... 'field.actions.update': 'Update', |
356 | ... } |
357 | - >>> view = create_initialized_view(series, name='+setbranch', |
358 | - ... principal=product.owner, form=form) |
359 | + >>> view = create_initialized_view( |
360 | + ... series, name='+setbranch', principal=driver, form=form) |
361 | >>> for notification in view.request.response.notifications: |
362 | ... print notification.message |
363 | >>> for error in view.errors: |
364 | @@ -286,13 +292,13 @@ |
365 | ... 'field.branch_type': 'import-external', |
366 | ... 'field.rcs_type': 'CVS', |
367 | ... 'field.branch_name': 'corvair-branch', |
368 | - ... 'field.branch_owner': product.owner.name, |
369 | + ... 'field.branch_owner': team.name, |
370 | ... 'field.repo_url': 'https://cvs.com/branch', |
371 | ... 'field.cvs_module': 'root', |
372 | ... 'field.actions.update': 'Update', |
373 | ... } |
374 | - >>> view = create_initialized_view(series, name='+setbranch', |
375 | - ... principal=product.owner, form=form) |
376 | + >>> view = create_initialized_view( |
377 | + ... series, name='+setbranch', principal=driver, form=form) |
378 | >>> for error in view.errors: |
379 | ... print error |
380 | >>> for notification in view.request.response.notifications: |
381 | @@ -308,12 +314,12 @@ |
382 | ... 'field.branch_type': 'import-external', |
383 | ... 'field.rcs_type': 'GIT', |
384 | ... 'field.branch_name': 'chevette-branch-dup', |
385 | - ... 'field.branch_owner': product.owner.name, |
386 | + ... 'field.branch_owner': team.name, |
387 | ... 'field.repo_url': 'git://github.com/chevette', |
388 | ... 'field.actions.update': 'Update', |
389 | ... } |
390 | - >>> view = create_initialized_view(series, name='+setbranch', |
391 | - ... principal=product.owner, form=form) |
392 | + >>> view = create_initialized_view( |
393 | + ... series, name='+setbranch', principal=driver, form=form) |
394 | >>> for error in view.errors: |
395 | ... print error |
396 | <BLANKLINE> |
397 | @@ -329,15 +335,15 @@ |
398 | ... 'field.branch_type': 'import-external', |
399 | ... 'field.rcs_type': 'GIT', |
400 | ... 'field.branch_name': 'chevette-branch', |
401 | - ... 'field.branch_owner': product.owner.name, |
402 | + ... 'field.branch_owner': team.name, |
403 | ... 'field.repo_url': 'git://github.com/different/chevette', |
404 | ... 'field.actions.update': 'Update', |
405 | ... } |
406 | - >>> view = create_initialized_view(series, name='+setbranch', |
407 | - ... principal=product.owner, form=form) |
408 | + >>> view = create_initialized_view( |
409 | + ... series, name='+setbranch', principal=driver, form=form) |
410 | >>> for error in view.errors: |
411 | ... print error |
412 | - You already have a branch for |
413 | + Team Name ... already has a branch for |
414 | <em>Chevy</em> called <em>chevette-branch</em>. |
415 | >>> print view.errors_in_action |
416 | True |
417 | @@ -354,12 +360,12 @@ |
418 | ... 'field.branch_type': 'import-external', |
419 | ... 'field.rcs_type': 'BZR', |
420 | ... 'field.branch_name': 'blazer-branch', |
421 | - ... 'field.branch_owner': product.owner.name, |
422 | + ... 'field.branch_owner': team.name, |
423 | ... 'field.repo_url': 'http://bzr.com/foo', |
424 | ... 'field.actions.update': 'Update', |
425 | ... } |
426 | >>> view = create_initialized_view( |
427 | - ... series, name='+setbranch', principal=product.owner, form=form) |
428 | + ... series, name='+setbranch', principal=driver, form=form) |
429 | >>> for error in view.errors: |
430 | ... print error |
431 | <BLANKLINE> |
268 + >>> print series. branch. registrant. name == driver.name
269 + True
No need for a print statement.