Roundup Tracker

Catch attempts to set the status to "resolved" - if the assignedto user isn't the creator, then set the status to "in-progress" (try "confirm-done" first though, but "classic" Roundup doesn't have that status).

This detector used to be distributed with the Roundup source as "creator_resolution.py"

   1 from roundup.exceptions import Reject
   2 
   3 def creator_resolution(db, cl, nodeid, newvalues):
   4     '''Catch attempts to set the status to "resolved" - if the assignedto
   5     user isn't the creator, then set the status to "in-progress" (try
   6     "confirm-done" first though, but "classic" Roundup doesn't have that
   7     status)
   8     '''
   9     if not newvalues.has_key('status'):
  10         return
  11 
  12     # get the resolved state ID
  13     resolved_id = db.status.lookup('resolved')
  14 
  15     if newvalues['status'] != resolved_id:
  16         return
  17 
  18     # check the assignedto
  19     assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto'))
  20     creator = cl.get(nodeid, 'creator')
  21     if assignedto == creator:
  22         if db.getuid() != creator:
  23             name = db.user.get(creator, 'username')
  24             raise Reject, 'Only the creator (%s) may close this issue'%name
  25         return
  26 
  27     # set the assignedto and status
  28     newvalues['assignedto'] = creator
  29     try:
  30         status = db.status.lookup('confirm-done')
  31     except KeyError:
  32         status = db.status.lookup('in-progress')
  33     newvalues['status'] = status
  34 
  35 def init(db):
  36     db.issue.audit('set', creator_resolution)


CategoryDetectors