Skip to content

Commit b15b69e

Browse files
committed
Restore sample detectors removed by 07c5d833dcb2 (issue2550574)
1 parent e66b147 commit b15b69e

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

detectors/creator_resolution.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This detector was written by [email protected] and it's been
2+
# placed in the Public Domain. Copy and modify to your heart's content.
3+
4+
#$Id: creator_resolution.py,v 1.2 2004-04-07 06:32:54 richard Exp $
5+
6+
from roundup.exceptions import Reject
7+
8+
def creator_resolution(db, cl, nodeid, newvalues):
9+
'''Catch attempts to set the status to "resolved" - if the assignedto
10+
user isn't the creator, then set the status to "in-progress" (try
11+
"confirm-done" first though, but "classic" Roundup doesn't have that
12+
status)
13+
'''
14+
if not newvalues.has_key('status'):
15+
return
16+
17+
# get the resolved state ID
18+
resolved_id = db.status.lookup('resolved')
19+
20+
if newvalues['status'] != resolved_id:
21+
return
22+
23+
# check the assignedto
24+
assignedto = newvalues.get('assignedto', cl.get(nodeid, 'assignedto'))
25+
creator = cl.get(nodeid, 'creator')
26+
if assignedto == creator:
27+
if db.getuid() != creator:
28+
name = db.user.get(creator, 'username')
29+
raise Reject, 'Only the creator (%s) may close this issue'%name
30+
return
31+
32+
# set the assignedto and status
33+
newvalues['assignedto'] = creator
34+
try:
35+
status = db.status.lookup('confirm-done')
36+
except KeyError:
37+
status = db.status.lookup('in-progress')
38+
newvalues['status'] = status
39+
40+
def init(db):
41+
db.issue.audit('set', creator_resolution)
42+
43+
# vim: set filetype=python ts=4 sw=4 et si

detectors/emailauditor.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
def eml_to_mht(db, cl, nodeid, newvalues):
3+
'''This auditor fires whenever a new file entity is created.
4+
5+
If the file is of type message/rfc822, we tack onthe extension .eml.
6+
7+
The reason for this is that Microsoft Internet Explorer will not open
8+
things with a .eml attachment, as they deem it 'unsafe'. Worse yet,
9+
they'll just give you an incomprehensible error message. For more
10+
information, please see:
11+
12+
http://support.microsoft.com/default.aspx?scid=kb;EN-US;825803
13+
14+
Their suggested work around is (excerpt):
15+
16+
WORKAROUND
17+
18+
To work around this behavior, rename the .EML file that the URL
19+
links to so that it has a .MHT file name extension, and then update
20+
the URL to reflect the change to the file name. To do this:
21+
22+
1. In Windows Explorer, locate and then select the .EML file that
23+
the URL links.
24+
2. Right-click the .EML file, and then click Rename.
25+
3. Change the file name so that the .EML file uses a .MHT file name
26+
extension, and then press ENTER.
27+
4. Updated the URL that links to the file to reflect the new file
28+
name extension.
29+
30+
So... we do that. :)'''
31+
if newvalues.get('type', '').lower() == "message/rfc822":
32+
if not newvalues.has_key('name'):
33+
newvalues['name'] = 'email.mht'
34+
return
35+
name = newvalues['name']
36+
if name.endswith('.eml'):
37+
name = name[:-4]
38+
newvalues['name'] = name + '.mht'
39+
40+
def init(db):
41+
db.file.audit('create', eml_to_mht)
42+

detectors/newissuecopy.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# copied from nosyreaction
2+
3+
from roundup import roundupdb
4+
5+
def newissuecopy(db, cl, nodeid, oldvalues):
6+
''' Copy a message about new issues to a team address.
7+
'''
8+
# so use all the messages in the create
9+
change_note = cl.generateCreateNote(nodeid)
10+
11+
# send a copy to the nosy list
12+
for msgid in cl.get(nodeid, 'messages'):
13+
try:
14+
# note: last arg must be a list
15+
cl.send_message(nodeid, msgid, change_note, ['[email protected]'])
16+
except roundupdb.MessageSendError, message:
17+
raise roundupdb.DetectorError, message
18+
19+
def init(db):
20+
db.issue.react('create', newissuecopy)
21+
22+
# vim: set filetype=python ts=4 sw=4 et si

0 commit comments

Comments
 (0)