77
88from roundup .exceptions import Unauthorised
99from roundup import hyperdb
10- from roundup . i18n import _
10+
1111
1212class Action :
1313 def __init__ (self , db , translator ):
@@ -24,20 +24,17 @@ def execute(self, *args):
2424 self .permission (* args )
2525 return self .handle (* args )
2626
27-
2827 def permission (self , * args ):
2928 """Check whether the user has permission to execute this action.
3029
3130 If not, raise Unauthorised."""
3231
3332 pass
3433
35-
3634 def gettext (self , msgid ):
3735 """Return the localized translation of msgid"""
3836 return self .translator .gettext (msgid )
3937
40-
4138 _ = gettext
4239
4340
@@ -47,11 +44,12 @@ def permission(self, designator):
4744 classname , itemid = hyperdb .splitDesignator (designator )
4845 perm = self .db .security .hasPermission
4946
50- if not perm ('Retire' , self .db .getuid (), classname = classname
51- , itemid = itemid ):
47+ if not perm ('Retire' , self .db .getuid (), classname = classname ,
48+ itemid = itemid ):
5249 raise Unauthorised (self ._ ('You do not have permission to retire '
5350 'or restore the %(classname)s class.' )
54- % locals ())
51+ % locals ())
52+
5553
5654class Retire (PermCheck ):
5755
@@ -61,7 +59,7 @@ def handle(self, designator):
6159
6260 # make sure we don't try to retire admin or anonymous
6361 if (classname == 'user' and
64- self .db .user .get (itemid , 'username' ) in ('admin' , 'anonymous' )):
62+ self .db .user .get (itemid , 'username' ) in ('admin' , 'anonymous' )):
6563 raise ValueError (self ._ (
6664 'You may not retire the admin or anonymous user' ))
6765
@@ -79,4 +77,3 @@ def handle(self, designator):
7977 # do the restore
8078 self .db .getclass (classname ).restore (itemid )
8179 self .db .commit ()
82-
0 commit comments