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.
4 #$Id: creator_resolution.py,v 1.2 2004-04-07 06:32:54 richard Exp $
6 from roundup.exceptions import Reject
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
17 # get the resolved state ID
18 resolved_id = db.status.lookup('resolved')
20 if newvalues['status'] != resolved_id:
21 return
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
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
40 def init(db):
41 db.issue.audit('set', creator_resolution)
43 # vim: set filetype=python ts=4 sw=4 et si