Skip to content

Commit b118998

Browse files
author
Roche Compaan
committed
Property changes are now listed in emails generated by Roundup
1 parent bbd177d commit b118998

File tree

3 files changed

+119
-14
lines changed

3 files changed

+119
-14
lines changed

roundup/roundupdb.py

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.23 2001-11-27 03:17:13 richard Exp $
18+
# $Id: roundupdb.py,v 1.24 2001-11-30 11:29:04 rochecompaan Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -268,7 +268,7 @@ def addmessage(self, nodeid, summary, text):
268268
appended to the "messages" field of the specified issue.
269269
"""
270270

271-
def sendmessage(self, nodeid, msgid):
271+
def sendmessage(self, nodeid, msgid, oldvalues):
272272
"""Send a message to the members of an issue's nosy list.
273273
274274
The message is sent only to users on the nosy list who are not
@@ -326,26 +326,33 @@ def sendmessage(self, nodeid, msgid):
326326
authaddr = ' <%s>'%authaddr
327327
else:
328328
authaddr = ''
329+
330+
# get the change note
331+
if oldvalues:
332+
change_note = self.generateChangeNote(nodeid, oldvalues)
333+
else:
334+
change_note = ''
335+
329336
# make the message body
330337
m = ['']
331338

332339
# put in roundup's signature
333340
if self.EMAIL_SIGNATURE_POSITION == 'top':
334-
m.append(self.email_signature(nodeid, msgid))
341+
m.append(self.email_signature(nodeid, msgid, change_note))
335342

336343
# add author information
337-
if len(self.db.issue.get(nodeid, 'messages')) == 1:
338-
m.append("New submission from %s%s:"%(authname, authaddr))
339-
else:
344+
if oldvalues:
340345
m.append("%s%s added the comment:"%(authname, authaddr))
346+
else:
347+
m.append("New submission from %s%s:"%(authname, authaddr))
341348
m.append('')
342349

343350
# add the content
344351
m.append(self.db.msg.get(msgid, 'content'))
345352

346-
# "list information" footer
353+
# put in roundup's signature
347354
if self.EMAIL_SIGNATURE_POSITION == 'bottom':
348-
m.append(self.email_signature(nodeid, msgid))
355+
m.append(self.email_signature(nodeid, msgid, change_note))
349356

350357
# get the files for this message
351358
files = self.db.msg.get(msgid, 'files')
@@ -406,16 +413,90 @@ def sendmessage(self, nodeid, msgid):
406413
raise MessageSendError, \
407414
"Couldn't send confirmation email: %s"%value
408415

409-
def email_signature(self, nodeid, msgid):
416+
def email_signature(self, nodeid, msgid, change_note):
410417
''' Add a signature to the e-mail with some useful information
411418
'''
412419
web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid
413420
email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL)
414421
line = '_' * max(len(web), len(email))
415-
return '%s\n%s\n%s\n%s'%(line, email, web, line)
422+
return '%s\n%s\n%s\n%s\n%s'%(line, email, web, change_note, line)
423+
424+
def generateChangeNote(self, nodeid, oldvalues):
425+
"""Generate a change note that lists property changes
426+
"""
427+
cn = self.classname
428+
cl = self.db.classes[cn]
429+
changed = {}
430+
props = cl.getprops(protected=0)
431+
432+
# determine what changed
433+
for key in props.keys():
434+
if key in ['files','messages']: continue
435+
new_value = cl.get(nodeid, key)
436+
# the old value might be non existent
437+
try:
438+
old_value = oldvalues[key]
439+
if type(old_value) is type([]):
440+
old_value.sort()
441+
new_value.sort()
442+
if old_value != new_value:
443+
changed[key] = old_value
444+
except:
445+
old_value = None
446+
changed[key] = old_value
447+
448+
# list the changes
449+
m = []
450+
for propname, oldvalue in changed.items():
451+
prop = cl.properties[propname]
452+
value = cl.get(nodeid, propname, None)
453+
change = '%s -> %s'%(oldvalue, value)
454+
if isinstance(prop, hyperdb.Link):
455+
link = self.db.classes[prop.classname]
456+
key = link.labelprop(default_to_id=1)
457+
if key:
458+
if value:
459+
value = link.get(value, key)
460+
else:
461+
value = ''
462+
if oldvalue:
463+
oldvalue = link.get(oldvalue, key)
464+
else:
465+
oldvalue = ''
466+
change = '%s -> %s'%(oldvalue, value)
467+
elif isinstance(prop, hyperdb.Multilink):
468+
if value is None: value = []
469+
l = []
470+
link = self.db.classes[prop.classname]
471+
key = link.labelprop(default_to_id=1)
472+
if oldvalue is None: oldvalue = []
473+
# check for additions
474+
for entry in value:
475+
if entry in oldvalue: continue
476+
if key:
477+
l.append(link.get(entry, key))
478+
else:
479+
l.append(entry)
480+
if l:
481+
change = '+%s'%(', '.join(l))
482+
l = []
483+
# check for removals
484+
for entry in oldvalue:
485+
if entry in value: continue
486+
if key:
487+
l.append(link.get(entry, key))
488+
else:
489+
l.append(entry)
490+
if l:
491+
change = change + ' -%s'%(', '.join(l))
492+
m.append('%s: %s'%(propname, change))
493+
return '\n'.join(m)
416494

417495
#
418496
# $Log: not supported by cvs2svn $
497+
# Revision 1.23 2001/11/27 03:17:13 richard
498+
# oops
499+
#
419500
# Revision 1.22 2001/11/27 03:00:50 richard
420501
# couple of bugfixes from latest patch integration
421502
#

roundup/templates/classic/detectors/nosyreaction.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.6 2001-11-26 22:55:56 richard Exp $
18+
#$Id: nosyreaction.py,v 1.7 2001-11-30 11:29:04 rochecompaan Exp $
1919

2020
from roundup import roundupdb
2121

@@ -54,7 +54,7 @@ def nosyreaction(db, cl, nodeid, oldvalues):
5454
# send a copy to the nosy list
5555
for msgid in messages:
5656
try:
57-
cl.sendmessage(nodeid, msgid)
57+
cl.sendmessage(nodeid, msgid, oldvalues)
5858
except roundupdb.MessageSendError, message:
5959
raise roundupdb.DetectorError, message
6060

@@ -89,6 +89,18 @@ def init(db):
8989

9090
#
9191
#$Log: not supported by cvs2svn $
92+
#Revision 1.6 2001/11/26 22:55:56 richard
93+
#Feature:
94+
# . Added INSTANCE_NAME to configuration - used in web and email to identify
95+
# the instance.
96+
# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
97+
# signature info in e-mails.
98+
# . Some more flexibility in the mail gateway and more error handling.
99+
# . Login now takes you to the page you back to the were denied access to.
100+
#
101+
#Fixed:
102+
# . Lots of bugs, thanks Roché and others on the devel mailing list!
103+
#
92104
#Revision 1.5 2001/11/12 22:01:07 richard
93105
#Fixed issues with nosy reaction and author copies.
94106
#

roundup/templates/extended/detectors/nosyreaction.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.6 2001-11-26 22:55:56 richard Exp $
18+
#$Id: nosyreaction.py,v 1.7 2001-11-30 11:29:04 rochecompaan Exp $
1919

2020
from roundup import roundupdb
2121

@@ -54,7 +54,7 @@ def nosyreaction(db, cl, nodeid, oldvalues):
5454
# send a copy to the nosy list
5555
for msgid in messages:
5656
try:
57-
cl.sendmessage(nodeid, msgid)
57+
cl.sendmessage(nodeid, msgid, oldvalues)
5858
except roundupdb.MessageSendError, message:
5959
raise roundupdb.DetectorError, message
6060

@@ -89,6 +89,18 @@ def init(db):
8989

9090
#
9191
#$Log: not supported by cvs2svn $
92+
#Revision 1.6 2001/11/26 22:55:56 richard
93+
#Feature:
94+
# . Added INSTANCE_NAME to configuration - used in web and email to identify
95+
# the instance.
96+
# . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
97+
# signature info in e-mails.
98+
# . Some more flexibility in the mail gateway and more error handling.
99+
# . Login now takes you to the page you back to the were denied access to.
100+
#
101+
#Fixed:
102+
# . Lots of bugs, thanks Roché and others on the devel mailing list!
103+
#
92104
#Revision 1.5 2001/11/12 22:01:07 richard
93105
#Fixed issues with nosy reaction and author copies.
94106
#

0 commit comments

Comments
 (0)