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
=== modified file 'lib/lp/code/browser/sourcepackagerecipebuild.py'
--- lib/lp/code/browser/sourcepackagerecipebuild.py 2010-07-14 10:27:35 +0000
+++ lib/lp/code/browser/sourcepackagerecipebuild.py 2010-07-24 14:29:47 +0000
@@ -27,6 +27,12 @@
27from lp.services.job.interfaces.job import JobStatus27from lp.services.job.interfaces.job import JobStatus
2828
2929
30UNEDITABLE_BUILD_STATES = (
31 BuildStatus.FULLYBUILT,
32 BuildStatus.FAILEDTOBUILD,
33 BuildStatus.SUPERSEDED,
34 BuildStatus.FAILEDTOUPLOAD,)
35
30class SourcePackageRecipeBuildNavigation(Navigation, FileNavigationMixin):36class SourcePackageRecipeBuildNavigation(Navigation, FileNavigationMixin):
3137
32 usedfor = ISourcePackageRecipeBuild38 usedfor = ISourcePackageRecipeBuild
@@ -43,7 +49,7 @@
4349
44 @enabled_with_permission('launchpad.Edit')50 @enabled_with_permission('launchpad.Edit')
45 def cancel(self):51 def cancel(self):
46 if self.context.buildqueue_record is None:52 if self.context.status in UNEDITABLE_BUILD_STATES:
47 enabled = False53 enabled = False
48 else:54 else:
49 enabled = True55 enabled = True
@@ -51,7 +57,7 @@
5157
52 @enabled_with_permission('launchpad.Edit')58 @enabled_with_permission('launchpad.Edit')
53 def rescore(self):59 def rescore(self):
54 if self.context.buildqueue_record is None:60 if self.context.status in UNEDITABLE_BUILD_STATES:
55 enabled = False61 enabled = False
56 else:62 else:
57 enabled = True63 enabled = True
5864
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-21 12:22:40 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-24 14:29:47 +0000
@@ -101,6 +101,7 @@
101 """If the build isn't queued, you can't cancel it."""101 """If the build isn't queued, you can't cancel it."""
102 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner102 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
103 build = self.makeRecipeBuild()103 build = self.makeRecipeBuild()
104 build.cancelBuild()
104 transaction.commit()105 transaction.commit()
105 build_url = canonical_url(build)106 build_url = canonical_url(build)
106 logout()107 logout()
@@ -181,6 +182,7 @@
181 """If the build isn't queued, you can't rescore it."""182 """If the build isn't queued, you can't rescore it."""
182 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner183 experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
183 build = self.makeRecipeBuild()184 build = self.makeRecipeBuild()
185 build.cancelBuild()
184 transaction.commit()186 transaction.commit()
185 build_url = canonical_url(build)187 build_url = canonical_url(build)
186 logout()188 logout()