"Fossies" - the Fresh Open Source Software Archive

Member "roundup-2.0.0/detectors/creator_resolution.py" (26 Aug 2019, 1352 Bytes) of package /linux/www/roundup-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "creator_resolution.py": 1.6.1_vs_2.0.0.

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