launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00180
Re: [Merge] lp:~gmb/launchpad/dont-piss-the-losas-off-bug-596877 into lp:launchpad
I've updated the branch per our discussions. Here comes the diff:
=== modified file 'lib/lp/bugs/browser/bugtracker.py'
--- lib/lp/bugs/browser/bugtracker.py 2010-07-17 19:19:16 +0000
+++ lib/lp/bugs/browser/bugtracker.py 2010-07-20 16:17:59 +0000
@@ -27,6 +27,7 @@
from zope.formlib import form
from zope.schema import Choice
from zope.schema.vocabulary import SimpleVocabulary
+from zope.security.interfaces import Unauthorized
from canonical.cachedproperty import cachedproperty
from canonical.database.sqlbase import flush_database_updates
@@ -63,10 +64,6 @@
)
-class UserCannotResetWatchesError(Exception):
- """Raised when a user cannot reset a bug tracker's watches."""
-
-
class BugTrackerSetNavigation(GetitemNavigation):
usedfor = IBugTrackerSet
@@ -387,11 +384,13 @@
def resetBugTrackerWatches(self):
"""Call the resetWatches() method of the current context.
- :raises `UserCannotResetWatchesError` if the user isn't an admin
+ :raises `Unauthorized` if the user isn't an admin
or a member of the Launchpad Developers team.
"""
if not self.user_can_reset_watches:
- raise UserCannotResetWatchesError
+ raise Unauthorized(
+ "You don't have permission to reset all the watches for "
+ "this bug tracker.")
self.context.resetWatches()
=== modified file 'lib/lp/bugs/browser/tests/test_bugtracker_views.py'
--- lib/lp/bugs/browser/tests/test_bugtracker_views.py 2010-07-17 16:59:12 +0000
+++ lib/lp/bugs/browser/tests/test_bugtracker_views.py 2010-07-20 16:17:59 +0000
@@ -11,12 +11,13 @@
from pytz import utc
from zope.component import getUtility
+from zope.security.interfaces import Unauthorized
from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
from canonical.testing.layers import DatabaseFunctionalLayer
from lp.bugs.browser.bugtracker import (
- BugTrackerEditView, UserCannotResetWatchesError)
+ BugTrackerEditView)
from lp.registry.interfaces.person import IPersonSet
from lp.testing import login, TestCaseWithFactory
from lp.testing.sampledata import ADMIN_EMAIL, NO_PRIVILEGE_EMAIL
@@ -70,7 +71,7 @@
login(NO_PRIVILEGE_EMAIL)
view = create_initialized_view(self.bug_tracker, '+edit')
self.assertRaises(
- UserCannotResetWatchesError, view.resetBugTrackerWatches)
+ Unauthorized, view.resetBugTrackerWatches)
def test_admin_can_reset_watches(self):
# Launchpad admins can reset the watches on a bugtracker.
--
https://code.launchpad.net/~gmb/launchpad/dont-piss-the-losas-off-bug-596877/+merge/30186
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/dont-piss-the-losas-off-bug-596877 into lp:launchpad.
References