Skip to content

Commit 531952b

Browse files
author
Roche Compaan
committed
Property changes are now completely traceable, whether changes are
made through the web or by email
1 parent 16318ff commit 531952b

File tree

2 files changed

+35
-47
lines changed

2 files changed

+35
-47
lines changed

roundup/cgi_client.py

Lines changed: 11 additions & 32 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: cgi_client.py,v 1.70 2001-11-30 00:06:29 richard Exp $
18+
# $Id: cgi_client.py,v 1.71 2001-11-30 20:28:10 rochecompaan Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -332,8 +332,10 @@ def shownode(self, message=None):
332332
note = self.form['__note']
333333
note = note.value
334334
if changed or note:
335+
p = self._post_editnode(self.nodeid, changed)
336+
props['messages'] = p['messages']
337+
props['files'] = p['files']
335338
cl.set(self.nodeid, **props)
336-
self._post_editnode(self.nodeid, changed)
337339
# and some nice feedback for the user
338340
message = _('%(changes)s edited ok')%{'changes':
339341
', '.join(changed)}
@@ -499,34 +501,6 @@ def _post_editnode(self, nid, changes=None):
499501
' the web.\n')%{'classname': cn}
500502
m = [summary]
501503

502-
# figure the changes and add them to the message
503-
first = 1
504-
for name, prop in props.items():
505-
if changes is not None and name not in changes: continue
506-
if first:
507-
m.append('\n-------')
508-
first = 0
509-
value = cl.get(nid, name, None)
510-
if isinstance(prop, hyperdb.Link):
511-
link = self.db.classes[prop.classname]
512-
key = link.labelprop(default_to_id=1)
513-
if value is not None and key:
514-
value = link.get(value, key)
515-
else:
516-
value = '-'
517-
elif isinstance(prop, hyperdb.Multilink):
518-
if value is None: value = []
519-
l = []
520-
link = self.db.classes[prop.classname]
521-
key = link.labelprop(default_to_id=1)
522-
for entry in value:
523-
if key:
524-
l.append(link.get(entry, key))
525-
else:
526-
l.append(entry)
527-
value = ', '.join(l)
528-
m.append('%s: %s'%(name, value))
529-
530504
# now create the message
531505
content = '\n'.join(m)
532506
message_id = self.db.msg.create(author=self.getuid(),
@@ -535,7 +509,7 @@ def _post_editnode(self, nid, changes=None):
535509
messages = cl.get(nid, 'messages')
536510
messages.append(message_id)
537511
props = {'messages': messages, 'files': files}
538-
cl.set(nid, **props)
512+
return props
539513

540514
def newnode(self, message=None):
541515
''' Add a new node to the database.
@@ -568,7 +542,8 @@ def newnode(self, message=None):
568542
props = {}
569543
try:
570544
nid = self._createnode()
571-
self._post_editnode(nid)
545+
props = self._post_editnode(nid)
546+
cl.set(nid, **props)
572547
# and some nice feedback for the user
573548
message = _('%(classname)s created ok')%{'classname': cn}
574549
except:
@@ -1049,6 +1024,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
10491024

10501025
#
10511026
# $Log: not supported by cvs2svn $
1027+
# Revision 1.70 2001/11/30 00:06:29 richard
1028+
# Converted roundup/cgi_client.py to use _()
1029+
# Added the status file, I18N_PROGRESS.txt
1030+
#
10521031
# Revision 1.69 2001/11/29 23:19:51 richard
10531032
# Removed the "This issue has been edited through the web" when a valid
10541033
# change note is supplied.

roundup/roundupdb.py

Lines changed: 24 additions & 15 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.24 2001-11-30 11:29:04 rochecompaan Exp $
18+
# $Id: roundupdb.py,v 1.25 2001-11-30 20:28:10 rochecompaan Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -310,8 +310,19 @@ def sendmessage(self, nodeid, msgid, oldvalues):
310310
if rlen == len(recipients):
311311
return
312312

313+
# get the change note
314+
if oldvalues:
315+
change_note = self.generateChangeNote(nodeid, oldvalues)
316+
else:
317+
change_note = ''
318+
319+
# add the change note to the message content
320+
content = self.db.msg.get(msgid, 'content')
321+
content += change_note
322+
313323
# update the message's recipients list
314324
self.db.msg.set(msgid, recipients=recipients)
325+
self.db.msg.setcontent('msg', msgid, content)
315326

316327
# send an email to the people who missed out
317328
sendto = [self.db.user.get(i, 'address') for i in recipients]
@@ -327,18 +338,12 @@ def sendmessage(self, nodeid, msgid, oldvalues):
327338
else:
328339
authaddr = ''
329340

330-
# get the change note
331-
if oldvalues:
332-
change_note = self.generateChangeNote(nodeid, oldvalues)
333-
else:
334-
change_note = ''
335-
336341
# make the message body
337342
m = ['']
338343

339344
# put in roundup's signature
340345
if self.EMAIL_SIGNATURE_POSITION == 'top':
341-
m.append(self.email_signature(nodeid, msgid, change_note))
346+
m.append(self.email_signature(nodeid, msgid))
342347

343348
# add author information
344349
if oldvalues:
@@ -348,11 +353,11 @@ def sendmessage(self, nodeid, msgid, oldvalues):
348353
m.append('')
349354

350355
# add the content
351-
m.append(self.db.msg.get(msgid, 'content'))
356+
m.append(content)
352357

353358
# put in roundup's signature
354359
if self.EMAIL_SIGNATURE_POSITION == 'bottom':
355-
m.append(self.email_signature(nodeid, msgid, change_note))
360+
m.append(self.email_signature(nodeid, msgid))
356361

357362
# get the files for this message
358363
files = self.db.msg.get(msgid, 'files')
@@ -364,7 +369,7 @@ def sendmessage(self, nodeid, msgid, oldvalues):
364369
writer.addheader('To', ', '.join(sendto))
365370
writer.addheader('From', '%s <%s>'%(self.INSTANCE_NAME,
366371
self.ISSUE_TRACKER_EMAIL))
367-
writer.addheader('Reply-To:', '%s <%s>'%(self.INSTANCE_NAME,
372+
writer.addheader('Reply-To', '%s <%s>'%(self.INSTANCE_NAME,
368373
self.ISSUE_TRACKER_EMAIL))
369374
writer.addheader('MIME-Version', '1.0')
370375

@@ -413,13 +418,13 @@ def sendmessage(self, nodeid, msgid, oldvalues):
413418
raise MessageSendError, \
414419
"Couldn't send confirmation email: %s"%value
415420

416-
def email_signature(self, nodeid, msgid, change_note):
421+
def email_signature(self, nodeid, msgid):
417422
''' Add a signature to the e-mail with some useful information
418423
'''
419424
web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid
420425
email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL)
421426
line = '_' * max(len(web), len(email))
422-
return '%s\n%s\n%s\n%s\n%s'%(line, email, web, change_note, line)
427+
return '%s\n%s\n%s\n%s'%(line, email, web, line)
423428

424429
def generateChangeNote(self, nodeid, oldvalues):
425430
"""Generate a change note that lists property changes
@@ -446,7 +451,7 @@ def generateChangeNote(self, nodeid, oldvalues):
446451
changed[key] = old_value
447452

448453
# list the changes
449-
m = []
454+
m = ['','----------']
450455
for propname, oldvalue in changed.items():
451456
prop = cl.properties[propname]
452457
value = cl.get(nodeid, propname, None)
@@ -465,6 +470,7 @@ def generateChangeNote(self, nodeid, oldvalues):
465470
oldvalue = ''
466471
change = '%s -> %s'%(oldvalue, value)
467472
elif isinstance(prop, hyperdb.Multilink):
473+
change = ''
468474
if value is None: value = []
469475
l = []
470476
link = self.db.classes[prop.classname]
@@ -488,12 +494,15 @@ def generateChangeNote(self, nodeid, oldvalues):
488494
else:
489495
l.append(entry)
490496
if l:
491-
change = change + ' -%s'%(', '.join(l))
497+
change += ' -%s'%(', '.join(l))
492498
m.append('%s: %s'%(propname, change))
493499
return '\n'.join(m)
494500

495501
#
496502
# $Log: not supported by cvs2svn $
503+
# Revision 1.24 2001/11/30 11:29:04 rochecompaan
504+
# Property changes are now listed in emails generated by Roundup
505+
#
497506
# Revision 1.23 2001/11/27 03:17:13 richard
498507
# oops
499508
#

0 commit comments

Comments
 (0)