Merge lp:~adeuring/launchpad/bug-758902 into lp:launchpad

Proposed by Abel Deuring
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 12825
Proposed branch: lp:~adeuring/launchpad/bug-758902
Merge into: lp:launchpad
Diff against target: 67 lines (+27/-10)
2 files modified
lib/lp/registry/browser/sourcepackage.py (+11/-7)
lib/lp/registry/browser/tests/sourcepackage-views.txt (+16/-3)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-758902
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+57502@code.launchpad.net

Commit message

[r=abentley][bug=758902] avoid an OOPS when somebody tries to delete a packaging link more than once.

Description of the change

This branch fixes bug 758902: "OOPS unlinking package association in translations details page"

The problem is trivial: PackagingUtil.deletePackaging() raises an assertion error if the the given productseries and sourcepackage are not/no longer linked by a packaging record.

The fix is equally trivial: SourcePackageRemoveUpstreamView.unlink() should call deletePackaging() if the packaging record still exists.

test: ./bin/test registry -vvt sourcepackage-views.txt

no lint

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/sourcepackage.py'
2--- lib/lp/registry/browser/sourcepackage.py 2011-04-13 05:38:13 +0000
3+++ lib/lp/registry/browser/sourcepackage.py 2011-04-13 14:46:52 +0000
4@@ -425,13 +425,17 @@
5 @action('Unlink')
6 def unlink(self, action, data):
7 old_series = self.context.productseries
8- getUtility(IPackagingUtil).deletePackaging(
9- self.context.productseries,
10- self.context.sourcepackagename,
11- self.context.distroseries)
12- self.request.response.addInfoNotification(
13- 'Removed upstream association between %s and %s.' % (
14- old_series.title, self.context.distroseries.displayname))
15+ if self.context.direct_packaging is not None:
16+ getUtility(IPackagingUtil).deletePackaging(
17+ self.context.productseries,
18+ self.context.sourcepackagename,
19+ self.context.distroseries)
20+ self.request.response.addInfoNotification(
21+ 'Removed upstream association between %s and %s.' % (
22+ old_series.title, self.context.distroseries.displayname))
23+ else:
24+ self.request.response.addInfoNotification(
25+ 'The packaging link has already been deleted.')
26
27
28 class SourcePackageView:
29
30=== modified file 'lib/lp/registry/browser/tests/sourcepackage-views.txt'
31--- lib/lp/registry/browser/tests/sourcepackage-views.txt 2011-04-11 16:00:53 +0000
32+++ lib/lp/registry/browser/tests/sourcepackage-views.txt 2011-04-13 14:46:52 +0000
33@@ -353,11 +353,11 @@
34 >>> print view.cancel_url
35 http://launchpad.dev/youbuntu/wonky/+source/stinkypackage
36
37- >>> login_person(package.packaging.owner)
38+ >>> user = package.packaging.owner
39+ >>> login_person(user)
40 >>> form = {'field.actions.unlink': 'Unlink'}
41 >>> view = create_initialized_view(
42- ... package, name='+remove-packaging', form=form,
43- ... principal=package.packaging.owner)
44+ ... package, name='+remove-packaging', form=form, principal=user)
45 >>> view.errors
46 []
47
48@@ -365,6 +365,19 @@
49 ... print notification.message
50 Removed upstream association between Stinky stinkyseries series and Wonky.
51
52+If somebody attempts to remove this packaging link a second time,
53+they get a message telling them that the link has already been
54+deleted.
55+
56+ >>> view = create_initialized_view(
57+ ... package, name='+remove-packaging', form=form, principal=user)
58+ >>> view.errors
59+ []
60+
61+ >>> for notification in view.request.response.notifications:
62+ ... print notification.message
63+ The packaging link has already been deleted.
64+
65 >>> view = create_initialized_view(package, name='+portlet-associations')
66 >>> print extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
67 Launchpad doesn’t know which project ...