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
=== modified file 'lib/canonical/launchpad/security.py'
--- lib/canonical/launchpad/security.py 2010-12-15 22:05:43 +0000
+++ lib/canonical/launchpad/security.py 2010-12-17 13:59:34 +0000
@@ -503,7 +503,7 @@
503 usedfor = ISpecificationPublic503 usedfor = ISpecificationPublic
504504
505505
506class EditSpecificationByTargetOwnerOrOwnersOrAdmins(AuthorizationBase):506class EditSpecificationByRelatedPeople(AuthorizationBase):
507 """We want everybody "related" to a specification to be able to edit it.507 """We want everybody "related" to a specification to be able to edit it.
508 You are related if you have a role on the spec, or if you have a role on508 You are related if you have a role on the spec, or if you have a role on
509 the spec target (distro/product) or goal (distroseries/productseries).509 the spec target (distro/product) or goal (distroseries/productseries).
@@ -520,6 +520,7 @@
520 return True520 return True
521 return (user.in_admin or521 return (user.in_admin or
522 user.isOwner(self.obj.target) or522 user.isOwner(self.obj.target) or
523 user.isOneOfDrivers(self.obj.target) or
523 user.isOneOf(524 user.isOneOf(
524 self.obj, ['owner', 'drafter', 'assignee', 'approver']))525 self.obj, ['owner', 'drafter', 'assignee', 'approver']))
525526
526527
=== modified file 'lib/lp/blueprints/tests/test_specification.py'
--- lib/lp/blueprints/tests/test_specification.py 2010-11-24 18:06:04 +0000
+++ lib/lp/blueprints/tests/test_specification.py 2010-12-17 13:59:34 +0000
@@ -9,16 +9,29 @@
9from zope.security.interfaces import Unauthorized9from zope.security.interfaces import Unauthorized
10from zope.security.proxy import removeSecurityProxy10from zope.security.proxy import removeSecurityProxy
1111
12from canonical.launchpad.webapp.authorization import check_permission
12from canonical.testing.layers import DatabaseFunctionalLayer13from canonical.testing.layers import DatabaseFunctionalLayer
13from lp.blueprints.errors import TargetAlreadyHasSpecification14from lp.blueprints.errors import TargetAlreadyHasSpecification
14from lp.blueprints.interfaces.specification import SpecificationGoalStatus15from lp.blueprints.interfaces.specification import SpecificationGoalStatus
15from lp.testing import TestCaseWithFactory16from lp.testing import (
17 login_person,
18 TestCaseWithFactory,
19 )
1620
1721
18class SpecificationTests(TestCaseWithFactory):22class SpecificationTests(TestCaseWithFactory):
1923
20 layer = DatabaseFunctionalLayer24 layer = DatabaseFunctionalLayer
2125
26 def test_target_driver_has_edit_rights(self):
27 """Drivers of a blueprint's target can edit that blueprint."""
28 product = self.factory.makeProduct()
29 driver = self.factory.makePerson()
30 removeSecurityProxy(product).driver = driver
31 specification = self.factory.makeSpecification(product=product)
32 login_person(driver)
33 self.assertTrue(check_permission('launchpad.Edit', specification))
34
22 def test_auto_accept_of_goal_for_drivers(self):35 def test_auto_accept_of_goal_for_drivers(self):
23 """Drivers of a series accept the goal when they propose."""36 """Drivers of a series accept the goal when they propose."""
24 product = self.factory.makeProduct()37 product = self.factory.makeProduct()
@@ -49,7 +62,7 @@
49 specification2 = self.factory.makeSpecification(62 specification2 = self.factory.makeSpecification(
50 product=product2, name="foo")63 product=product2, name="foo")
51 self.assertRaises(64 self.assertRaises(
52 TargetAlreadyHasSpecification, 65 TargetAlreadyHasSpecification,
53 removeSecurityProxy(specification1).retarget, product2)66 removeSecurityProxy(specification1).retarget, product2)
5467
55 def test_retarget_is_protected(self):68 def test_retarget_is_protected(self):