← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/recipe-buildnow-permission into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #769762 in Launchpad itself: ""Build now" button is shown even if you haven't the permission request builds"
  https://bugs.launchpad.net/launchpad/+bug/769762

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/recipe-buildnow-permission/+merge/59380

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
-- 
https://code.launchpad.net/~wallyworld/launchpad/recipe-buildnow-permission/+merge/59380
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/recipe-buildnow-permission into lp:launchpad.
=== 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:25 +0000
@@ -106,7 +106,6 @@
 from lp.code.model.branchtarget import PersonBranchTarget
 from lp.code.model.sourcepackagerecipe import get_buildable_distroseries_set
 from lp.registry.interfaces.series import SeriesStatus
-from lp.services.features import getFeatureFlag
 from lp.services.propertycache import cachedproperty
 from lp.soyuz.model.archive import Archive
 
@@ -197,6 +196,8 @@
             has_upload = ppa.checkArchivePermission(recipe.owner)
             show_request_build = has_upload
 
+        show_request_build= (show_request_build and
+            check_permission('launchpad.Edit', recipe))
         return Link(
                 '+request-daily-build', 'Build now',
                 enabled=show_request_build)

=== 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:25 +0000
@@ -1288,6 +1288,17 @@
         build_button = find_tag_by_id(browser.contents, 'field.actions.build')
         self.assertIs(None, build_button)
 
+    def test_request_daily_builds_button_no_recipe_permission(self):
+        # Recipes do not have a build now link if the user does not have edit
+        # permission on the recipe.
+        login(ANONYMOUS)
+        recipe = self.factory.makeSourcePackageRecipe(
+            owner=self.chef, is_stale=True, build_daily=True)
+        person = self.factory.makePerson()
+        browser = self.getViewBrowser(recipe, user=person)
+        build_button = find_tag_by_id(browser.contents, 'field.actions.build')
+        self.assertIs(None, build_button)
+
     def test_request_daily_builds_button_ppa_with_no_permissions(self):
         # Recipes that have a daily build ppa without upload permissions
         # do not have a build now link