@@ -7,7 +7,52 @@ def preset_new(db, cl, nodeid, newvalues):
77 new = db .status .lookup ('new' )
88 newvalues ['status' ] = new
99
10+ def update_pending (db , cl , nodeid , newvalues ):
11+ ''' If the issue is currently 'pending' and person other than assigned
12+ updates it, then set it to 'open'.
13+ '''
14+ # don't fire if there's no new message (ie. update)
15+ if 'messages' not in newvalues :
16+ return
17+ if newvalues ['messages' ] == cl .get (nodeid , 'messages' ):
18+ return
19+
20+ # get the open state ID
21+ try :
22+ open_id = db .status .lookup ('open' )
23+ except KeyError :
24+ # no open state, ignore all this stuff
25+ return
26+
27+ # get the current value
28+ current_status = cl .get (nodeid , 'status' )
29+
30+ # see if there's an explicit change in this transaction
31+ if 'status' in newvalues :
32+ # yep, skip
33+ return
34+
35+ assignee = cl .get (nodeid , 'assignee' )
36+ if assignee == db .getuid ():
37+ # this change is brought to you by the assignee and number 4
38+ # so don't change status.
39+ return
40+
41+ # determine the id of 'pending'
42+ fromstates = []
43+ for state in 'pending' .split ():
44+ try :
45+ fromstates .append (db .status .lookup (state ))
46+ except KeyError :
47+ pass
48+
49+ # ok, there's no explicit change, so check if we are in a state that
50+ # should be changed
51+ if current_status in fromstates + [None ]:
52+ # yep, we're now open
53+ newvalues ['status' ] = open_id
1054
1155def init (db ):
1256 # fire before changes are made
1357 db .issue .audit ('create' , preset_new )
58+ db .issue .audit ('set' , update_pending )
0 commit comments