Merge lp:~wallyworld/launchpad/recipe-buildnow-permission into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 12951
Proposed branch: lp:~wallyworld/launchpad/recipe-buildnow-permission
Merge into: lp:launchpad
Diff against target: 42 lines (+13/-1)
2 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+2/-1)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+11/-0)
To merge this branch: bzr merge lp:~wallyworld/launchpad/recipe-buildnow-permission
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+59380@code.launchpad.net

Commit message

[r=jcsackett][bug=769762] Do not show recipe build now if user does not have edit permission on recipe.

Description of the change

Do not show recipe build now if user does not have edit permission on recipe.

== Implementation ==

Small tweak to request_daily_build() on SourcePackageRecipeContextMenu - check for recipe edit permission.

== Tests ==

Add new test test_request_daily_builds_button_no_recipe_permission() to TestSourcePackageRecipeView

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/browser/sourcepackagerecipe.py
  lib/lp/code/browser/tests/test_sourcepackagerecipe.py

./lib/lp/code/browser/tests/test_sourcepackagerecipe.py
     483: E501 line too long (80 characters)
    1101: E501 line too long (85 characters)
    1131: E501 line too long (85 characters)
    1166: E501 line too long (85 characters)
     238: Line exceeds 78 characters.
     483: Line exceeds 78 characters.
    1101: Line exceeds 78 characters.
    1131: Line exceeds 78 characters.
    1153: Line exceeds 78 characte

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good.

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/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py 2011-04-11 01:30:37 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py 2011-04-28 14:49:42 +0000
@@ -106,7 +106,6 @@
106from lp.code.model.branchtarget import PersonBranchTarget106from lp.code.model.branchtarget import PersonBranchTarget
107from lp.code.model.sourcepackagerecipe import get_buildable_distroseries_set107from lp.code.model.sourcepackagerecipe import get_buildable_distroseries_set
108from lp.registry.interfaces.series import SeriesStatus108from lp.registry.interfaces.series import SeriesStatus
109from lp.services.features import getFeatureFlag
110from lp.services.propertycache import cachedproperty109from lp.services.propertycache import cachedproperty
111from lp.soyuz.model.archive import Archive110from lp.soyuz.model.archive import Archive
112111
@@ -197,6 +196,8 @@
197 has_upload = ppa.checkArchivePermission(recipe.owner)196 has_upload = ppa.checkArchivePermission(recipe.owner)
198 show_request_build = has_upload197 show_request_build = has_upload
199198
199 show_request_build= (show_request_build and
200 check_permission('launchpad.Edit', recipe))
200 return Link(201 return Link(
201 '+request-daily-build', 'Build now',202 '+request-daily-build', 'Build now',
202 enabled=show_request_build)203 enabled=show_request_build)
203204
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-04-18 22:38:52 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-04-28 14:49:42 +0000
@@ -1288,6 +1288,17 @@
1288 build_button = find_tag_by_id(browser.contents, 'field.actions.build')1288 build_button = find_tag_by_id(browser.contents, 'field.actions.build')
1289 self.assertIs(None, build_button)1289 self.assertIs(None, build_button)
12901290
1291 def test_request_daily_builds_button_no_recipe_permission(self):
1292 # Recipes do not have a build now link if the user does not have edit
1293 # permission on the recipe.
1294 login(ANONYMOUS)
1295 recipe = self.factory.makeSourcePackageRecipe(
1296 owner=self.chef, is_stale=True, build_daily=True)
1297 person = self.factory.makePerson()
1298 browser = self.getViewBrowser(recipe, user=person)
1299 build_button = find_tag_by_id(browser.contents, 'field.actions.build')
1300 self.assertIs(None, build_button)
1301
1291 def test_request_daily_builds_button_ppa_with_no_permissions(self):1302 def test_request_daily_builds_button_ppa_with_no_permissions(self):
1292 # Recipes that have a daily build ppa without upload permissions1303 # Recipes that have a daily build ppa without upload permissions
1293 # do not have a build now link1304 # do not have a build now link