Mercurial > p > roundup > code
annotate detectors/creator_resolution.py @ 3909:e89bcb28f683
indexargs_url force ids to int
ids appear as hyperdb.String instances, which confused indexargs_url when they
appear in the filterspec. They need to be treated as treated as integers when
generating URLs.
It feels sort of hacky to check for 'id' like this but I'm at a loss for what
else to do in this case. Suggestions are welcome :)
Maybe we should look into using some other hyperdb class to represent ids?
this fixes [SF#783492]
Some trailing whitespace also got trimmed.
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Tue, 18 Sep 2007 16:59:42 +0000 |
| parents | 43151ac10819 |
| children |
| rev | line source |
|---|---|
|
2194
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
1 # This detector was written by richard@mechanicalcat.net and it's been |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
2 # placed in the Public Domain. Copy and modify to your heart's content. |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
3 |
|
43151ac10819
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
2193
diff
changeset
|
4 #$Id: creator_resolution.py,v 1.2 2004-04-07 06:32:54 richard Exp $ |
|
2193
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 from roundup.exceptions import Reject |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 def creator_resolution(db, cl, nodeid, newvalues): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 '''Catch attempts to set the status to "resolved" - if the assignedto |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 user isn't the creator, then set the status to "in-progress" (try |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 "confirm-done" first though, but "classic" Roundup doesn't have that |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 status) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 ''' |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 if not newvalues.has_key('status'): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 # get the resolved state ID |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 resolved_id = db.status.lookup('resolved') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 if newvalues['status'] != resolved_id: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 # check the assignedto |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto')) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 creator = cl.get(nodeid, 'creator') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 if assignedto == creator: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 if db.getuid() != creator: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 name = db.user.get(creator, 'username') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 raise Reject, 'Only the creator (%s) may close this issue'%name |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 return |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 # set the assignedto and status |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 newvalues['assignedto'] = creator |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 try: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 status = db.status.lookup('confirm-done') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 except KeyError: |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 status = db.status.lookup('in-progress') |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 newvalues['status'] = status |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 def init(db): |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 db.issue.audit('set', creator_resolution) |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 |
|
b1a29edd6214
added another sample detector
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 # vim: set filetype=python ts=4 sw=4 et si |
