"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/actions.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

actions.py  (roundup-1.6.1):actions.py  (roundup-2.0.0)
# #
# Copyright (C) 2009 Stefan Seefeld # Copyright (C) 2009 Stefan Seefeld
# All rights reserved. # All rights reserved.
# For license terms see the file COPYING.txt. # For license terms see the file COPYING.txt.
# Actions used in REST and XMLRPC APIs
# #
from roundup.exceptions import Unauthorised from roundup.exceptions import Unauthorised
from roundup import hyperdb from roundup import hyperdb
from roundup.i18n import _
class Action: class Action:
def __init__(self, db, translator): def __init__(self, db, translator):
self.db = db self.db = db
self.translator = translator self.translator = translator
def handle(self, *args): def handle(self, *args):
"""Action handler procedure""" """Action handler procedure"""
raise NotImplementedError raise NotImplementedError
skipping to change at line 39 skipping to change at line 39
If not, raise Unauthorised.""" If not, raise Unauthorised."""
pass pass
def gettext(self, msgid): def gettext(self, msgid):
"""Return the localized translation of msgid""" """Return the localized translation of msgid"""
return self.translator.gettext(msgid) return self.translator.gettext(msgid)
_ = gettext _ = gettext
class Retire(Action): class PermCheck(Action):
def permission(self, designator):
classname, itemid = hyperdb.splitDesignator(designator)
perm = self.db.security.hasPermission
if not perm('Retire', self.db.getuid(), classname=classname,
itemid=itemid):
raise Unauthorised(self._('You do not have permission to retire '
'or restore the %(classname)s class.')
% locals())
class Retire(PermCheck):
def handle(self, designator): def handle(self, designator):
classname, itemid = hyperdb.splitDesignator(designator) classname, itemid = hyperdb.splitDesignator(designator)
# make sure we don't try to retire admin or anonymous # make sure we don't try to retire admin or anonymous
if (classname == 'user' and if (classname == 'user' and
self.db.user.get(itemid, 'username') in ('admin', 'anonymous')): self.db.user.get(itemid, 'username') in ('admin', 'anonymous')):
raise ValueError(self._( raise ValueError(self._(
'You may not retire the admin or anonymous user')) 'You may not retire the admin or anonymous user'))
# do the retire # do the retire
self.db.getclass(classname).retire(itemid) self.db.getclass(classname).retire(itemid)
self.db.commit() self.db.commit()
def permission(self, designator): class Restore(PermCheck):
def handle(self, designator):
classname, itemid = hyperdb.splitDesignator(designator) classname, itemid = hyperdb.splitDesignator(designator)
if not self.db.security.hasPermission('Edit', self.db.getuid(), # do the restore
classname=classname, itemid=itemid self.db.getclass(classname).restore(itemid)
): self.db.commit()
raise Unauthorised(self._('You do not have permission to '
'retire the %(classname)s class.')%classna
me)
 End of changes. 6 change blocks. 
4 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)