Mercurial > p > roundup > code
annotate roundup/actions.py @ 7658:d30e534b078a
clarify doc on dispatcher_email config setting.
An issue was brought up on the mailing list.
https://sourceforge.net/p/roundup/mailman/message/43383465/
The description of dispatcher_email sounds like it should be sent
email on issue creation. That's not it's role. Try to make it's role
more obvious.
Fix config.ini and reference.txt description.
Add the newissuecopy.py detector to send email on the creation of an
issue
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 10 Oct 2023 20:33:22 -0400 |
| parents | 4c9acc580769 |
| children | 1287b0c3d261 |
| rev | line source |
|---|---|
| 4083 | 1 # |
| 2 # Copyright (C) 2009 Stefan Seefeld | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5604 | 5 # Actions used in REST and XMLRPC APIs |
| 4083 | 6 # |
| 7 | |
|
5071
a7541077cf12
Remove 'import *' statement from actions.py
John Kristensen <john@jerrykan.com>
parents:
4357
diff
changeset
|
8 from roundup.exceptions import Unauthorised |
| 4083 | 9 from roundup import hyperdb |
| 6003 | 10 |
| 4083 | 11 |
| 12 class Action: | |
| 13 def __init__(self, db, translator): | |
| 14 self.db = db | |
| 15 self.translator = translator | |
| 16 | |
| 17 def handle(self, *args): | |
| 18 """Action handler procedure""" | |
| 19 raise NotImplementedError | |
| 20 | |
| 21 def execute(self, *args): | |
| 22 """Execute the action specified by this object.""" | |
| 23 | |
| 24 self.permission(*args) | |
| 25 return self.handle(*args) | |
| 26 | |
| 27 def permission(self, *args): | |
| 28 """Check whether the user has permission to execute this action. | |
| 29 | |
| 30 If not, raise Unauthorised.""" | |
| 31 | |
| 32 pass | |
| 33 | |
| 34 def gettext(self, msgid): | |
| 35 """Return the localized translation of msgid""" | |
| 36 return self.translator.gettext(msgid) | |
| 37 | |
| 38 _ = gettext | |
| 39 | |
| 40 | |
| 5604 | 41 class PermCheck(Action): |
| 42 def permission(self, designator): | |
| 43 | |
| 44 classname, itemid = hyperdb.splitDesignator(designator) | |
| 45 perm = self.db.security.hasPermission | |
| 46 | |
| 6003 | 47 if not perm('Retire', self.db.getuid(), classname=classname, |
| 48 itemid=itemid): | |
| 5604 | 49 raise Unauthorised(self._('You do not have permission to retire ' |
| 50 'or restore the %(classname)s class.') | |
| 6003 | 51 % locals()) |
| 52 | |
| 5604 | 53 |
| 54 class Retire(PermCheck): | |
| 4083 | 55 |
| 56 def handle(self, designator): | |
| 57 | |
| 58 classname, itemid = hyperdb.splitDesignator(designator) | |
| 59 | |
| 60 # make sure we don't try to retire admin or anonymous | |
| 61 if (classname == 'user' and | |
|
7176
4c9acc580769
chore: flake8 whitespace fixes
John Rouillard <rouilj@ieee.org>
parents:
6003
diff
changeset
|
62 self.db.user.get(itemid, 'username') in ('admin', 'anonymous')): |
|
4c9acc580769
chore: flake8 whitespace fixes
John Rouillard <rouilj@ieee.org>
parents:
6003
diff
changeset
|
63 |
|
4357
13b3155869e0
Beginnings of a big code cleanup / modernisation to make 2to3 happy
Richard Jones <richard@users.sourceforge.net>
parents:
4125
diff
changeset
|
64 raise ValueError(self._( |
|
13b3155869e0
Beginnings of a big code cleanup / modernisation to make 2to3 happy
Richard Jones <richard@users.sourceforge.net>
parents:
4125
diff
changeset
|
65 'You may not retire the admin or anonymous user')) |
| 4083 | 66 |
| 67 # do the retire | |
| 68 self.db.getclass(classname).retire(itemid) | |
| 69 self.db.commit() | |
| 70 | |
| 71 | |
| 5604 | 72 class Restore(PermCheck): |
| 73 | |
| 74 def handle(self, designator): | |
| 4083 | 75 |
| 76 classname, itemid = hyperdb.splitDesignator(designator) | |
| 77 | |
| 5604 | 78 # do the restore |
| 79 self.db.getclass(classname).restore(itemid) | |
| 80 self.db.commit() |
