← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/bugtask-userHasPrivileges-nomination into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/bugtask-userHasPrivileges-nomination into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #603732 in Launchpad itself: "If there is no driver a maintainer should be able to accept a bug nomination"
  https://bugs.launchpad.net/launchpad/+bug/603732

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/bugtask-userHasPrivileges-nomination/+merge/84041

Rather than checking if the user is an admin or a driver, call IBugTask.userHasPrivileges() for each task in IBugNomination.canApprove().
-- 
https://code.launchpad.net/~stevenk/launchpad/bugtask-userHasPrivileges-nomination/+merge/84041
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/bugtask-userHasPrivileges-nomination into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugnomination.py'
--- lib/lp/bugs/model/bugnomination.py	2011-05-27 21:12:25 +0000
+++ lib/lp/bugs/model/bugnomination.py	2011-12-01 00:53:26 +0000
@@ -120,10 +120,8 @@
 
     def canApprove(self, person):
         """See IBugNomination."""
-        if person.inTeam(getUtility(ILaunchpadCelebrities).admin):
-            return True
-        for driver in self.target.drivers:
-            if person.inTeam(driver):
+        for task in self.bug.bugtasks:
+            if task.userHasPrivileges(person):
                 return True
 
         if self.distroseries is not None:

=== modified file 'lib/lp/bugs/tests/test_bugnomination.py'
--- lib/lp/bugs/tests/test_bugnomination.py	2011-11-17 11:44:08 +0000
+++ lib/lp/bugs/tests/test_bugnomination.py	2011-12-01 00:53:26 +0000
@@ -14,6 +14,7 @@
     LessThan,
     Not,
     )
+from zope.component import getUtility
 
 from canonical.database.sqlbase import flush_database_updates
 from canonical.launchpad.ftests import (
@@ -21,6 +22,7 @@
     logout,
     )
 from canonical.testing.layers import DatabaseFunctionalLayer
+from lp.registry.interfaces.person import IPersonSet
 from lp.soyuz.interfaces.publishing import PackagePublishingStatus
 from lp.testing import (
     celebrity_logged_in,
@@ -29,6 +31,7 @@
     TestCaseWithFactory,
     )
 from lp.testing.matchers import HasQueryCount
+from lp.testing.sampledata import ADMIN_EMAIL
 
 
 class CanBeNominatedForTestMixin:
@@ -130,11 +133,17 @@
             target=self.factory.makeProductSeries())
         self.assertFalse(nomination.canApprove(self.factory.makePerson()))
 
-    def test_driver_can_approve(self):
+    def test_privileged_users_can_approve(self):
         product = self.factory.makeProduct(driver=self.factory.makePerson())
+        supervisor = self.factory.makePerson()
+        admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
+        with person_logged_in(admin):
+            product.setBugSupervisor(supervisor, admin)
         nomination = self.factory.makeBugNomination(
             target=self.factory.makeProductSeries(product=product))
+        self.assertTrue(nomination.canApprove(product.owner))
         self.assertTrue(nomination.canApprove(product.driver))
+        self.assertTrue(nomination.canApprove(supervisor))
 
     def publishSource(self, series, sourcepackagename, component):
         return self.factory.makeSourcePackagePublishingHistory(