Merge lp:~rockstar/launchpad/cancel-rescore-redux into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11230
Proposed branch: lp:~rockstar/launchpad/cancel-rescore-redux
Merge into: lp:launchpad
Diff against target: 54 lines (+10/-2)
2 files modified
lib/lp/code/browser/sourcepackagerecipebuild.py (+8/-2)
lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py (+2/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/cancel-rescore-redux
Reviewer Review Type Date Requested Status
Curtis Hovey (community) Approve
Review via email: mp+30856@code.launchpad.net

Description of the change

While doing some QA, I noticed that our new Cancel and Rescore actions aren't liberal enough in when they allow us to get to them. Basically, I was checking for a buildqueue, when sometimes it can be in a non-final state and not have a buildqueue (although this specific case we found might also be a bug, not sure yet).

This branch just fixes those two issues.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Nice fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/sourcepackagerecipebuild.py'
2--- lib/lp/code/browser/sourcepackagerecipebuild.py 2010-07-14 10:27:35 +0000
3+++ lib/lp/code/browser/sourcepackagerecipebuild.py 2010-07-24 14:29:47 +0000
4@@ -27,6 +27,12 @@
5 from lp.services.job.interfaces.job import JobStatus
6
7
8+UNEDITABLE_BUILD_STATES = (
9+ BuildStatus.FULLYBUILT,
10+ BuildStatus.FAILEDTOBUILD,
11+ BuildStatus.SUPERSEDED,
12+ BuildStatus.FAILEDTOUPLOAD,)
13+
14 class SourcePackageRecipeBuildNavigation(Navigation, FileNavigationMixin):
15
16 usedfor = ISourcePackageRecipeBuild
17@@ -43,7 +49,7 @@
18
19 @enabled_with_permission('launchpad.Edit')
20 def cancel(self):
21- if self.context.buildqueue_record is None:
22+ if self.context.status in UNEDITABLE_BUILD_STATES:
23 enabled = False
24 else:
25 enabled = True
26@@ -51,7 +57,7 @@
27
28 @enabled_with_permission('launchpad.Edit')
29 def rescore(self):
30- if self.context.buildqueue_record is None:
31+ if self.context.status in UNEDITABLE_BUILD_STATES:
32 enabled = False
33 else:
34 enabled = True
35
36=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py'
37--- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-21 12:22:40 +0000
38+++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-24 14:29:47 +0000
39@@ -101,6 +101,7 @@
40 """If the build isn't queued, you can't cancel it."""
41 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
42 build = self.makeRecipeBuild()
43+ build.cancelBuild()
44 transaction.commit()
45 build_url = canonical_url(build)
46 logout()
47@@ -181,6 +182,7 @@
48 """If the build isn't queued, you can't rescore it."""
49 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
50 build = self.makeRecipeBuild()
51+ build.cancelBuild()
52 transaction.commit()
53 build_url = canonical_url(build)
54 logout()