TracZephyrPlugin: Print more information about changed tickets.
authorAnders Kaseorg <andersk@mit.edu>
Tue, 30 Jun 2009 22:17:23 +0000 (18:17 -0400)
committerAnders Kaseorg <andersk@mit.edu>
Tue, 30 Jun 2009 22:22:41 +0000 (18:22 -0400)
TracZephyrPlugin/ZephyrPlugin.py

index 88fc2e1aec58031e0f325b7fdb3d5d70f542fc4d..fe46914b486df5c0421e11671329332672f55ddf 100644 (file)
@@ -35,14 +35,25 @@ class ZephyrPlugin(Component):
         self.zwrite(ticket.id, message)
     
     def ticket_changed(self, ticket, comment, author, old_values):
-        if old_values.has_key('status'):
-            if ticket['status'] == 'closed':
-                message = "%s closed ticket as %s\n(%s)" % (author, ticket['resolution'], ticket['summary'])
+        message = ''
+        for field in ticket.fields:
+            name = field['name']
+            if name not in old_values:
+                pass
+            elif field['type'] == 'textarea':
+                message += "%s changed %s to:\n%s\n" % (author, name, self.format_text(ticket[name]))
+            elif ticket[name] and old_values[name]:
+                message += "%s changed %s from %s to %s.\n" % (author, name, old_values[name], ticket[name])
+            elif ticket[name]:
+                message += "%s set %s to %s.\n" % (author, name, ticket[name])
+            elif old_values[name]:
+                message += "%s deleted %s.\n" % (author, name)
             else:
-                message = "%s set status to %s\n(%s)" % (author, ticket['status'], ticket['summary'])
-        else:
-            message = "%s updated this ticket\n(%s)" % (author, ticket['summary'])
+                message += "%s changed %s.\n" % (author, name)
+        if comment:
+            message += "%s commented:\n%s\n" % (author, self.format_text(comment))
         self.zwrite(ticket.id, message)
     
     def ticket_deleted(self, ticket):
-        pass
+        message = "%s deleted ticket %d" % (author, ticket.id)
+        self.zwrite(ticket.id, message)