Mercurial > p > roundup > code
comparison detectors/creator_resolution.py @ 4627:6b32e9dac625
Restore sample detectors removed by 07c5d833dcb2 (issue2550574)
| author | Thomas Arendsen Hein <thomas@intevation.de> |
|---|---|
| date | Wed, 16 May 2012 11:17:03 +0200 |
| parents | |
| children | b3f46759b4d1 |
comparison
equal
deleted
inserted
replaced
| 4626:e3cd5fcf710b | 4627:6b32e9dac625 |
|---|---|
| 1 # This detector was written by richard@mechanicalcat.net and it's been | |
| 2 # placed in the Public Domain. Copy and modify to your heart's content. | |
| 3 | |
| 4 #$Id: creator_resolution.py,v 1.2 2004-04-07 06:32:54 richard Exp $ | |
| 5 | |
| 6 from roundup.exceptions import Reject | |
| 7 | |
| 8 def creator_resolution(db, cl, nodeid, newvalues): | |
| 9 '''Catch attempts to set the status to "resolved" - if the assignedto | |
| 10 user isn't the creator, then set the status to "in-progress" (try | |
| 11 "confirm-done" first though, but "classic" Roundup doesn't have that | |
| 12 status) | |
| 13 ''' | |
| 14 if not newvalues.has_key('status'): | |
| 15 return | |
| 16 | |
| 17 # get the resolved state ID | |
| 18 resolved_id = db.status.lookup('resolved') | |
| 19 | |
| 20 if newvalues['status'] != resolved_id: | |
| 21 return | |
| 22 | |
| 23 # check the assignedto | |
| 24 assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto')) | |
| 25 creator = cl.get(nodeid, 'creator') | |
| 26 if assignedto == creator: | |
| 27 if db.getuid() != creator: | |
| 28 name = db.user.get(creator, 'username') | |
| 29 raise Reject, 'Only the creator (%s) may close this issue'%name | |
| 30 return | |
| 31 | |
| 32 # set the assignedto and status | |
| 33 newvalues['assignedto'] = creator | |
| 34 try: | |
| 35 status = db.status.lookup('confirm-done') | |
| 36 except KeyError: | |
| 37 status = db.status.lookup('in-progress') | |
| 38 newvalues['status'] = status | |
| 39 | |
| 40 def init(db): | |
| 41 db.issue.audit('set', creator_resolution) | |
| 42 | |
| 43 # vim: set filetype=python ts=4 sw=4 et si |
