From 4616108fc7b0f4ddc49f696bdbfdfe99243585de Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 24 Oct 2012 18:18:44 -0400 Subject: [PATCH] humbug_trac: Update display of field changes. (imported from commit 20253fb28273d80a5d8f69b1fd60545c2fb545bb) --- humbug_trac.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/humbug_trac.py b/humbug_trac.py index 5951007..e95dfcb 100644 --- a/humbug_trac.py +++ b/humbug_trac.py @@ -56,18 +56,22 @@ class HelloWorldPlugin(Component): def ticket_changed(self, ticket, comment, author, old_values): """Called when a ticket is modified. - + `old_values` is a dictionary containing the previous values of the fields that have changed. """ content = "%s updated %s:\n\n" % (author, markdown_ticket_url(ticket)) for key in old_values.keys(): - if key != "description": - content += '- Changed %s from "%s" to "%s"\n' % (key, old_values.get(key), - ticket.values.get(key)) - else: - content += '- Changed %s from %s to %s' % (key, markdown_block(old_values.get(key)), + if key == "description": + content += '- Changed %s from %s to %s' % (key, markdown_block(old_values.get(key)), markdown_block(ticket.values.get(key))) + elif old_values.get(key) == "": + content += '- Added %s **%s**\n' % (key, ticket.values.get(key)) + elif ticket.values.get(key) == "": + content += '- Remove %s **%s**\n' % (key, old_values.get(key)) + else: + content += '- Changed %s from **%s** to **%s**\n' % (key, old_values.get(key), + ticket.values.get(key)) if comment: content += '- Added a comment: %s' % (markdown_block(comment,))