Merge lp:~stevenk/launchpad/no-render-sprrdb into lp:launchpad

Proposed by Steve Kowalik on 2012-09-24
Status: Merged
Approved by: Steve Kowalik on 2012-09-24
Approved revision: no longer in the source branch.
Merged at revision: 16011
Proposed branch: lp:~stevenk/launchpad/no-render-sprrdb
Merge into: lp:launchpad
Diff against target: 35 lines (+14/-0)
2 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+5/-0)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+9/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/no-render-sprrdb
Reviewer Review Type Date Requested Status
Ian Booth (community) 2012-09-24 Approve on 2012-09-24
Review via email: mp+125930@code.launchpad.net

Commit Message

Redirect back to the recipe if the method is GET for SourcePackageRecipe:+request-daily-build.

Description of the Change

SourcePackageRecipe:+request-daily-build is not a usual form. It will request a build on submit, but there are no knobs to tweak if you hit it via a GET. If it is, redirect them back to the recipe.

To post a comment you must log in.
Ian Booth (wallyworld) wrote :

Looks ok

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/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2012-09-05 05:08:26 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2012-09-24 06:33:20 +0000
4@@ -541,6 +541,11 @@
5 # Attributes for the html version
6 page_title = "Build now"
7
8+ def initialize(self):
9+ super(SourcePackageRecipeRequestDailyBuildView, self).initialize()
10+ if self.request.method == 'GET':
11+ self.request.response.redirect(canonical_url(self.context))
12+
13 class schema(Interface):
14 """Schema for requesting a build."""
15
16
17=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
18--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2012-09-18 18:36:09 +0000
19+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2012-09-24 06:33:20 +0000
20@@ -1276,6 +1276,15 @@
21 self.assertEqual(
22 [build6, build5, build4, build3, build2], view.builds)
23
24+ def test_request_builds_redirects_on_get(self):
25+ recipe = self.factory.makeSourcePackageRecipe(
26+ owner=self.chef, daily_build_archive=self.ppa,
27+ is_stale=True, build_daily=True)
28+ with person_logged_in(self.chef):
29+ url = canonical_url(recipe)
30+ browser = self.getViewBrowser(recipe, '+request-daily-build')
31+ self.assertEqual(url, browser.url)
32+
33 def test_request_daily_builds_button_stale(self):
34 # Recipes that are stale and are built daily have a build now link
35 recipe = self.factory.makeSourcePackageRecipe(