← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Paul Hummer has proposed merging lp:~rockstar/launchpad/cancel-rescore-redux into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #609212 Cancel build for recipes has a bad enabled rule
  https://bugs.launchpad.net/bugs/609212
  #609215 Rescore build for recipes has a bad enabled rule
  https://bugs.launchpad.net/bugs/609215


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.
-- 
https://code.launchpad.net/~rockstar/launchpad/cancel-rescore-redux/+merge/30856
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rockstar/launchpad/cancel-rescore-redux into lp:launchpad/devel.
=== 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:19:48 +0000
@@ -27,6 +27,12 @@
 from lp.services.job.interfaces.job import JobStatus
 
 
+UNEDITABLE_BUILD_STATES = (
+    BuildStatus.FULLYBUILT,
+    BuildStatus.FAILEDTOBUILD,
+    BuildStatus.SUPERSEDED,
+    BuildStatus.FAILEDTOUPLOAD,)
+
 class SourcePackageRecipeBuildNavigation(Navigation, FileNavigationMixin):
 
     usedfor = ISourcePackageRecipeBuild
@@ -43,7 +49,7 @@
 
     @enabled_with_permission('launchpad.Edit')
     def cancel(self):
-        if self.context.buildqueue_record is None:
+        if self.context.buildstate in UNEDITABLE_BUILD_STATES:
             enabled = False
         else:
             enabled = True
@@ -51,7 +57,7 @@
 
     @enabled_with_permission('launchpad.Edit')
     def rescore(self):
-        if self.context.buildqueue_record is None:
+        if self.context.buildstate in UNEDITABLE_BUILD_STATES:
             enabled = False
         else:
             enabled = True

=== 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:19:48 +0000
@@ -101,6 +101,7 @@
         """If the build isn't queued, you can't cancel it."""
         experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
         build = self.makeRecipeBuild()
+        build.cancelBuild()
         transaction.commit()
         build_url = canonical_url(build)
         logout()
@@ -181,6 +182,7 @@
         """If the build isn't queued, you can't rescore it."""
         experts = getUtility(ILaunchpadCelebrities).bazaar_experts.teamowner
         build = self.makeRecipeBuild()
+        build.cancelBuild()
         transaction.commit()
         build_url = canonical_url(build)
         logout()