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

Proposed by Ian Booth on 2011-04-28
Status: Merged
Approved by: Ian Booth on 2011-04-28
Approved revision: 12943
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
To merge this branch: bzr merge lp:~wallyworld/launchpad/recipe-buildnow-permission
Reviewer Review Type Date Requested Status
j.c.sackett 2011-04-28 Approve on 2011-04-28
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.
j.c.sackett (jcsackett) wrote :

Looks good.

review: Approve

Preview Diff

1=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2011-04-11 01:30:37 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2011-04-28 14:49:42 +0000
4@@ -106,7 +106,6 @@
5 from lp.code.model.branchtarget import PersonBranchTarget
6 from lp.code.model.sourcepackagerecipe import get_buildable_distroseries_set
7 from lp.registry.interfaces.series import SeriesStatus
8-from lp.services.features import getFeatureFlag
9 from lp.services.propertycache import cachedproperty
10 from lp.soyuz.model.archive import Archive
11
12@@ -197,6 +196,8 @@
13 has_upload = ppa.checkArchivePermission(recipe.owner)
14 show_request_build = has_upload
15
16+ show_request_build= (show_request_build and
17+ check_permission('launchpad.Edit', recipe))
18 return Link(
19 '+request-daily-build', 'Build now',
20 enabled=show_request_build)
21
22=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
23--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-04-18 22:38:52 +0000
24+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2011-04-28 14:49:42 +0000
25@@ -1288,6 +1288,17 @@
26 build_button = find_tag_by_id(browser.contents, 'field.actions.build')
27 self.assertIs(None, build_button)
28
29+ def test_request_daily_builds_button_no_recipe_permission(self):
30+ # Recipes do not have a build now link if the user does not have edit
31+ # permission on the recipe.
32+ login(ANONYMOUS)
33+ recipe = self.factory.makeSourcePackageRecipe(
34+ owner=self.chef, is_stale=True, build_daily=True)
35+ person = self.factory.makePerson()
36+ browser = self.getViewBrowser(recipe, user=person)
37+ build_button = find_tag_by_id(browser.contents, 'field.actions.build')
38+ self.assertIs(None, build_button)
39+
40 def test_request_daily_builds_button_ppa_with_no_permissions(self):
41 # Recipes that have a daily build ppa without upload permissions
42 # do not have a build now link