From bc55de059258e0b9c371a43f53c84f02123caa9f Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 7 Apr 2004 06:31:47 +0000 Subject: [PATCH] added another sample detector git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2264 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + detectors/creator_resolution.py | 40 +++++++++++++++++++++++++++++++++ doc/customizing.txt | 39 +++++++++++++------------------- 3 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 detectors/creator_resolution.py diff --git a/CHANGES.txt b/CHANGES.txt index 0e8da95..f718a39 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,7 @@ Feature: - database export now exports full journals too - tracker name at end of page title (sf rfe 926840) - roundup-server now uses the ForkingMixin +- added another sample detector "creator_resolution" Fixed: - web CSV export was busted (as was any action returning a result) diff --git a/detectors/creator_resolution.py b/detectors/creator_resolution.py new file mode 100644 index 0000000..39be2f3 --- /dev/null +++ b/detectors/creator_resolution.py @@ -0,0 +1,40 @@ +#$Id: creator_resolution.py,v 1.1 2004-04-07 06:31:47 richard Exp $ + +from roundup.exceptions import Reject + +def creator_resolution(db, cl, nodeid, newvalues): + '''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) + ''' + if not newvalues.has_key('status'): + return + + # get the resolved state ID + resolved_id = db.status.lookup('resolved') + + if newvalues['status'] != resolved_id: + return + + # check the assignedto + assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto')) + creator = cl.get(nodeid, 'creator') + if assignedto == creator: + if db.getuid() != creator: + name = db.user.get(creator, 'username') + raise Reject, 'Only the creator (%s) may close this issue'%name + return + + # set the assignedto and status + newvalues['assignedto'] = creator + try: + status = db.status.lookup('confirm-done') + except KeyError: + status = db.status.lookup('in-progress') + newvalues['status'] = status + +def init(db): + db.issue.audit('set', creator_resolution) + +# vim: set filetype=python ts=4 sw=4 et si diff --git a/doc/customizing.txt b/doc/customizing.txt index 243eb03..ddcd33e 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -2,7 +2,7 @@ Customising Roundup =================== -:Version: $Revision: 1.132 $ +:Version: $Revision: 1.133 $ .. This document borrows from the ZopeBook section on ZPT. The original is at: http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx @@ -585,6 +585,9 @@ interface for detectors. __ design.html +Additional Detectors Ready For Use +---------------------------------- + Sample additional detectors that have been found useful will appear in the ``'detectors'`` directory of the Roundup distribution. If you want to use one, copy it to the ``'detectors'`` of your tracker instance: @@ -594,28 +597,18 @@ to use one, copy it to the ``'detectors'`` of your tracker instance: created. The address is hard-coded into the detector, so edit it before you use it (look for the text 'team@team.host') or you'll get email errors! - - The detector code:: - - from roundup import roundupdb - - def newissuecopy(db, cl, nodeid, oldvalues): - ''' Copy a message about new issues to a team address. - ''' - # so use all the messages in the create - change_note = cl.generateCreateNote(nodeid) - - # send a copy to the nosy list - for msgid in cl.get(nodeid, 'messages'): - try: - # note: last arg must be a list - cl.send_message(nodeid, msgid, change_note, - ['team@team.host']) - except roundupdb.MessageSendError, message: - raise roundupdb.DetectorError, message - - def init(db): - db.issue.react('create', newissuecopy) +**creator_resolution.py** + Catch attempts to set the status to "resolved" - if the assignedto + user isn't the creator, then set the status to "confirm-done". Note that + "classic" Roundup doesn't have that status, so you'll have to add it. If + you don't want to though, it'll just use "in-progress" instead. +**email_auditor.py** + If a file added to an issue is of type message/rfc822, we tack on the + extension .eml. + The reason for this is that Microsoft Internet Explorer will not open + things with a .eml attachment, as they deem it 'unsafe'. Worse yet, + they'll just give you an incomprehensible error message. For more + information, see the detector code - it has a length explanation. Auditor or Reactor? -- 2.30.2