Merge lp:~salgado/launchpad/target-driver-edit-blueprint into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 12099
Proposed branch: lp:~salgado/launchpad/target-driver-edit-blueprint
Merge into: lp:launchpad
Diff against target: 64 lines (+17/-3)
2 files modified
lib/canonical/launchpad/security.py (+2/-1)
lib/lp/blueprints/tests/test_specification.py (+15/-2)
To merge this branch: bzr merge lp:~salgado/launchpad/target-driver-edit-blueprint
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+44046@code.launchpad.net

Commit message

[r=bac][ui=none][bug=691559] Allow the drivers of a blueprint's target to edit that blueprint.

Description of the change

Allow the drivers of a blueprint's target to edit that blueprint.

That's something we need for Linaro and is consistent with allowing the goal's
drivers to edit, which is something we already do.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Hi Salgado,

Please change EditSpecificationByTargetOwnerOrOwnersOrAdmins to something less wieldy and more accurate as it is now misleading.
EditSpecificationsByRelatedPeople ?

Otherwise this looks good.

Let me know when the changes are made and I'll send it through ec2 to land for you.

review: Approve (code)
Revision history for this message
Guilherme Salgado (salgado) wrote :

To QA this you must find/create a blueprint in which you're not the assignee/approver/owner. Then make yourself the driver (but not the owner) of that blueprint's product/distro and try to edit it (e.g. +setproductseries). I'll ask Alexander Sack to keep an eye out for this as he should be able to help with QA if needed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/security.py'
2--- lib/canonical/launchpad/security.py 2010-12-15 22:05:43 +0000
3+++ lib/canonical/launchpad/security.py 2010-12-17 13:59:34 +0000
4@@ -503,7 +503,7 @@
5 usedfor = ISpecificationPublic
6
7
8-class EditSpecificationByTargetOwnerOrOwnersOrAdmins(AuthorizationBase):
9+class EditSpecificationByRelatedPeople(AuthorizationBase):
10 """We want everybody "related" to a specification to be able to edit it.
11 You are related if you have a role on the spec, or if you have a role on
12 the spec target (distro/product) or goal (distroseries/productseries).
13@@ -520,6 +520,7 @@
14 return True
15 return (user.in_admin or
16 user.isOwner(self.obj.target) or
17+ user.isOneOfDrivers(self.obj.target) or
18 user.isOneOf(
19 self.obj, ['owner', 'drafter', 'assignee', 'approver']))
20
21
22=== modified file 'lib/lp/blueprints/tests/test_specification.py'
23--- lib/lp/blueprints/tests/test_specification.py 2010-11-24 18:06:04 +0000
24+++ lib/lp/blueprints/tests/test_specification.py 2010-12-17 13:59:34 +0000
25@@ -9,16 +9,29 @@
26 from zope.security.interfaces import Unauthorized
27 from zope.security.proxy import removeSecurityProxy
28
29+from canonical.launchpad.webapp.authorization import check_permission
30 from canonical.testing.layers import DatabaseFunctionalLayer
31 from lp.blueprints.errors import TargetAlreadyHasSpecification
32 from lp.blueprints.interfaces.specification import SpecificationGoalStatus
33-from lp.testing import TestCaseWithFactory
34+from lp.testing import (
35+ login_person,
36+ TestCaseWithFactory,
37+ )
38
39
40 class SpecificationTests(TestCaseWithFactory):
41
42 layer = DatabaseFunctionalLayer
43
44+ def test_target_driver_has_edit_rights(self):
45+ """Drivers of a blueprint's target can edit that blueprint."""
46+ product = self.factory.makeProduct()
47+ driver = self.factory.makePerson()
48+ removeSecurityProxy(product).driver = driver
49+ specification = self.factory.makeSpecification(product=product)
50+ login_person(driver)
51+ self.assertTrue(check_permission('launchpad.Edit', specification))
52+
53 def test_auto_accept_of_goal_for_drivers(self):
54 """Drivers of a series accept the goal when they propose."""
55 product = self.factory.makeProduct()
56@@ -49,7 +62,7 @@
57 specification2 = self.factory.makeSpecification(
58 product=product2, name="foo")
59 self.assertRaises(
60- TargetAlreadyHasSpecification,
61+ TargetAlreadyHasSpecification,
62 removeSecurityProxy(specification1).retarget, product2)
63
64 def test_retarget_is_protected(self):