Changeset 90 for emailtotracscript
- Timestamp:
- 06/30/06 09:55:09 (18 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/ChangeLog
r89 r90 19 19 - Catch a LookupError in unicode/encode conversion 20 20 Fixed by: Bas van der Vlies 21 22 - Description field was always changed when updating the ticket 23 via the web. Asked the mailing list for a solution and got one 24 ;-) 25 Patch/Suggestion by: Christian Boos 26 Applied by: Bas van der Vlies 21 27 22 28 2006-06-02 -
emailtotracscript/trunk/debian/changelog
r89 r90 1 email2trac (0.7.3-5) stable; urgency=low 2 3 * Description always changed when accesing the ticket via the web. 4 Suggestion/Patch by: Christian Boos 5 6 -- root <root@subtrac.sara.nl> Fri, 30 Jun 2006 09:50:32 +0200 7 1 8 email2trac (0.7.3-4) stable; urgency=low 2 9 -
emailtotracscript/trunk/email2trac.py.in
r89 r90 408 408 409 409 body_text = self.get_body_text(msg) 410 tkt['description'] = '' 411 412 # Insert ticket in database with empty description 413 # 410 body_text = ('\r\n'.join(body_text.splitlines())) 411 412 # A patch so that the web-interface will not update the description 413 # field of a ticket 414 # 415 tkt['description'] = u'email2trac:%s\r\n{{{\r\n%s\r\n}}}' \ 416 %(head, body_text) 417 414 418 when = int(time.time()) 415 419 if self.VERSION == 0.8: 416 tkt['id'] = tkt.insert(self.db) 417 else: 418 tkt['id'] = tkt.insert() 420 ticket_id = tkt.insert(self.db) 421 else: 422 ticket_id = tkt.insert() 423 424 changed = False 425 comment = '' 426 427 # Rewrite the description if we have mailto enabled 428 # 429 if self.MAILTO: 430 mailto = self.html_mailto_link(self.to_unicode(msg['subject']), ticket_id, body_text) 431 tkt['description'] = u'email2trac:%s%s\r\n{{{\r\n%s\r\n}}}' %(head, mailto, body_text) 432 comment = '\nadded mailto line\n' 433 changed = True 419 434 420 435 n = self.attachments(msg, tkt) 421 436 if n: 422 attach_str = '\nThis message has %d attachment(s)\n' %(n) 423 else: 424 attach_str = '' 425 426 # Always update the description else we get two emails one for the new ticket 427 # and for the attachments. It is an ugly hack but with trac you can not add 428 # attachments without an ticket id 429 # 430 mailto = '' 431 if self.MAILTO: 432 mailto = self.html_mailto_link(self.to_unicode(msg['subject']), tkt['id'], body_text) 433 tkt['description'] = '%s%s%s\n{{{\n%s\n}}}\n' %(head, attach_str, mailto, body_text) 434 comment = 'Added mailto: link + description' 435 else: 436 tkt['description'] = '%s%s\n{{{\n%s\n}}}\n' %(head, attach_str, body_text) 437 comment = 'Added description' 438 439 # Save the real description and other changes 440 # 441 if self.VERSION == 0.8: 442 tkt.save_changes(self.db, self.author, comment, when) 443 else: 444 tkt.save_changes(self.author, comment, when) 437 comment = '%s\nThis message has %d attachment(s)\n' %(comment, n) 438 changed = True 439 440 if changed: 441 if self.VERSION == 0.8: 442 tkt.save_changes(self.db, self.author, comment) 443 else: 444 tkt.save_changes(self.author, comment) 445 446 #print tkt.get_changelog(self.db, when) 445 447 446 448 if self.notification: 447 self.notify(tkt, True, when) 449 self.notify(tkt, True) 450 #self.notify(tkt, False) 448 451 449 452 def parse(self, fp): … … 478 481 """ 479 482 has_description = 0 480 ubody_text = '\ n{{{\nNo plain text message\n}}}\n'483 ubody_text = '\r\n{{{\nNo plain text message\n}}}\r\n' 481 484 for part in msg.walk(): 482 485 … … 489 492 # Try to decode, if fails then do not decode 490 493 # 491 body_text = part.get_payload(decode=1) 494 body_text = part.get_payload(decode=1) 492 495 if not body_text: 493 body_text = part.get_payload(decode=0) 496 body_text = part.get_payload(decode=0) 494 497 495 498 # Get contents charset (iso-8859-15 if not defined in mail headers) … … 497 500 # 498 501 charset = part.get_content_charset('iso-8859-15') 499 500 502 try: 501 503 temp = unicode(body_text, charset) … … 503 505 temp = unicode(body_text, 'iso-8859-15') 504 506 505 #ubody_text = unicode(body_text, charset).encode('utf-8')506 507 ubody_text = temp.encode('utf-8') 507 508 508 509 elif part.get_content_type() == 'text/html': 509 ubody_text = '\ n\n(see attachment for HTML mail message)\n'510 511 else: 512 ubody_text = '\ n\n(see attachment for message)\n'510 ubody_text = '\r\n(see attachment for HTML mail message)\r\n' 511 512 else: 513 ubody_text = '\r\n(see attachment for message)\r\n' 513 514 514 515 has_description = 1 … … 516 517 517 518 if not has_description: 518 ubody_text = '\ n\n(see attachment for message)\n'519 ubody_text = '\r\n(see attachment for message)\r\n' 519 520 520 521 return ubody_text … … 563 564 ) 564 565 565 str = '\ n{{{\n#!html\n<a href="%s">Reply to: %s</a>\n}}}\n' %(str, author)566 str = '\r\n{{{\r\n#!html\r\n<a href="%s">Reply to: %s</a>\r\n}}}\r\n' %(str, author) 566 567 567 568 return str
Note: See TracChangeset
for help on using the changeset viewer.