comparison roundup/roundupdb.py @ 428:7956563d49ae

Property changes are now completely traceable, whether changes are made through the web or by email
author Roche Compaan <rochecompaan@users.sourceforge.net>
date Fri, 30 Nov 2001 20:28:10 +0000
parents fc907b6ef135
children 2441743e335b
comparison
equal deleted inserted replaced
427:5164f3141159 428:7956563d49ae
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
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 $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Extending hyperdb with types specific to issue-tracking. 21 Extending hyperdb with types specific to issue-tracking.
22 """ 22 """
23 23
308 308
309 # no new recipients 309 # no new recipients
310 if rlen == len(recipients): 310 if rlen == len(recipients):
311 return 311 return
312 312
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
313 # update the message's recipients list 323 # update the message's recipients list
314 self.db.msg.set(msgid, recipients=recipients) 324 self.db.msg.set(msgid, recipients=recipients)
325 self.db.msg.setcontent('msg', msgid, content)
315 326
316 # send an email to the people who missed out 327 # send an email to the people who missed out
317 sendto = [self.db.user.get(i, 'address') for i in recipients] 328 sendto = [self.db.user.get(i, 'address') for i in recipients]
318 cn = self.classname 329 cn = self.classname
319 title = self.get(nodeid, 'title') or '%s message copy'%cn 330 title = self.get(nodeid, 'title') or '%s message copy'%cn
325 if authaddr: 336 if authaddr:
326 authaddr = ' <%s>'%authaddr 337 authaddr = ' <%s>'%authaddr
327 else: 338 else:
328 authaddr = '' 339 authaddr = ''
329 340
330 # get the change note
331 if oldvalues:
332 change_note = self.generateChangeNote(nodeid, oldvalues)
333 else:
334 change_note = ''
335
336 # make the message body 341 # make the message body
337 m = [''] 342 m = ['']
338 343
339 # put in roundup's signature 344 # put in roundup's signature
340 if self.EMAIL_SIGNATURE_POSITION == 'top': 345 if self.EMAIL_SIGNATURE_POSITION == 'top':
341 m.append(self.email_signature(nodeid, msgid, change_note)) 346 m.append(self.email_signature(nodeid, msgid))
342 347
343 # add author information 348 # add author information
344 if oldvalues: 349 if oldvalues:
345 m.append("%s%s added the comment:"%(authname, authaddr)) 350 m.append("%s%s added the comment:"%(authname, authaddr))
346 else: 351 else:
347 m.append("New submission from %s%s:"%(authname, authaddr)) 352 m.append("New submission from %s%s:"%(authname, authaddr))
348 m.append('') 353 m.append('')
349 354
350 # add the content 355 # add the content
351 m.append(self.db.msg.get(msgid, 'content')) 356 m.append(content)
352 357
353 # put in roundup's signature 358 # put in roundup's signature
354 if self.EMAIL_SIGNATURE_POSITION == 'bottom': 359 if self.EMAIL_SIGNATURE_POSITION == 'bottom':
355 m.append(self.email_signature(nodeid, msgid, change_note)) 360 m.append(self.email_signature(nodeid, msgid))
356 361
357 # get the files for this message 362 # get the files for this message
358 files = self.db.msg.get(msgid, 'files') 363 files = self.db.msg.get(msgid, 'files')
359 364
360 # create the message 365 # create the message
362 writer = MimeWriter.MimeWriter(message) 367 writer = MimeWriter.MimeWriter(message)
363 writer.addheader('Subject', '[%s%s] %s'%(cn, nodeid, title)) 368 writer.addheader('Subject', '[%s%s] %s'%(cn, nodeid, title))
364 writer.addheader('To', ', '.join(sendto)) 369 writer.addheader('To', ', '.join(sendto))
365 writer.addheader('From', '%s <%s>'%(self.INSTANCE_NAME, 370 writer.addheader('From', '%s <%s>'%(self.INSTANCE_NAME,
366 self.ISSUE_TRACKER_EMAIL)) 371 self.ISSUE_TRACKER_EMAIL))
367 writer.addheader('Reply-To:', '%s <%s>'%(self.INSTANCE_NAME, 372 writer.addheader('Reply-To', '%s <%s>'%(self.INSTANCE_NAME,
368 self.ISSUE_TRACKER_EMAIL)) 373 self.ISSUE_TRACKER_EMAIL))
369 writer.addheader('MIME-Version', '1.0') 374 writer.addheader('MIME-Version', '1.0')
370 375
371 # attach files 376 # attach files
372 if files: 377 if files:
411 "Couldn't send confirmation email: mailhost %s"%value 416 "Couldn't send confirmation email: mailhost %s"%value
412 except smtplib.SMTPException, value: 417 except smtplib.SMTPException, value:
413 raise MessageSendError, \ 418 raise MessageSendError, \
414 "Couldn't send confirmation email: %s"%value 419 "Couldn't send confirmation email: %s"%value
415 420
416 def email_signature(self, nodeid, msgid, change_note): 421 def email_signature(self, nodeid, msgid):
417 ''' Add a signature to the e-mail with some useful information 422 ''' Add a signature to the e-mail with some useful information
418 ''' 423 '''
419 web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid 424 web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid
420 email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL) 425 email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL)
421 line = '_' * max(len(web), len(email)) 426 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)
423 428
424 def generateChangeNote(self, nodeid, oldvalues): 429 def generateChangeNote(self, nodeid, oldvalues):
425 """Generate a change note that lists property changes 430 """Generate a change note that lists property changes
426 """ 431 """
427 cn = self.classname 432 cn = self.classname
444 except: 449 except:
445 old_value = None 450 old_value = None
446 changed[key] = old_value 451 changed[key] = old_value
447 452
448 # list the changes 453 # list the changes
449 m = [] 454 m = ['','----------']
450 for propname, oldvalue in changed.items(): 455 for propname, oldvalue in changed.items():
451 prop = cl.properties[propname] 456 prop = cl.properties[propname]
452 value = cl.get(nodeid, propname, None) 457 value = cl.get(nodeid, propname, None)
453 change = '%s -> %s'%(oldvalue, value) 458 change = '%s -> %s'%(oldvalue, value)
454 if isinstance(prop, hyperdb.Link): 459 if isinstance(prop, hyperdb.Link):
463 oldvalue = link.get(oldvalue, key) 468 oldvalue = link.get(oldvalue, key)
464 else: 469 else:
465 oldvalue = '' 470 oldvalue = ''
466 change = '%s -> %s'%(oldvalue, value) 471 change = '%s -> %s'%(oldvalue, value)
467 elif isinstance(prop, hyperdb.Multilink): 472 elif isinstance(prop, hyperdb.Multilink):
473 change = ''
468 if value is None: value = [] 474 if value is None: value = []
469 l = [] 475 l = []
470 link = self.db.classes[prop.classname] 476 link = self.db.classes[prop.classname]
471 key = link.labelprop(default_to_id=1) 477 key = link.labelprop(default_to_id=1)
472 if oldvalue is None: oldvalue = [] 478 if oldvalue is None: oldvalue = []
486 if key: 492 if key:
487 l.append(link.get(entry, key)) 493 l.append(link.get(entry, key))
488 else: 494 else:
489 l.append(entry) 495 l.append(entry)
490 if l: 496 if l:
491 change = change + ' -%s'%(', '.join(l)) 497 change += ' -%s'%(', '.join(l))
492 m.append('%s: %s'%(propname, change)) 498 m.append('%s: %s'%(propname, change))
493 return '\n'.join(m) 499 return '\n'.join(m)
494 500
495 # 501 #
496 # $Log: not supported by cvs2svn $ 502 # $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 #
497 # Revision 1.23 2001/11/27 03:17:13 richard 506 # Revision 1.23 2001/11/27 03:17:13 richard
498 # oops 507 # oops
499 # 508 #
500 # Revision 1.22 2001/11/27 03:00:50 richard 509 # Revision 1.22 2001/11/27 03:00:50 richard
501 # couple of bugfixes from latest patch integration 510 # couple of bugfixes from latest patch integration

Roundup Issue Tracker: http://roundup-tracker.org/