Ticket #1069: trac-xmlrpc-ticketnitify.patch
| File trac-xmlrpc-ticketnitify.patch, 3.3 kB (added by stp, 2 years ago) |
|---|
-
tracrpc/api.py
old new 224 224 version number, second is the minor. Changes to the major version 225 225 indicate API breaking changes, while minor version changes are simple 226 226 additions, bug fixes, etc. """ 227 return [0, 1]227 return [0, 2] -
tracrpc/ticket.py
old new 5 5 import trac.ticket.model as model 6 6 import trac.ticket.query as query 7 7 from trac.ticket.api import TicketSystem 8 from trac.ticket.notification import TicketNotifyEmail 8 9 10 import time 9 11 import pydoc 10 12 import xmlrpclib 11 13 from StringIO import StringIO … … 24 26 yield ('TICKET_VIEW', ((list, xmlrpclib.DateTime),), self.getRecentChanges) 25 27 yield ('TICKET_VIEW', ((list, int),), self.getAvailableActions) 26 28 yield ('TICKET_VIEW', ((list, int),), self.get) 27 yield ('TICKET_CREATE', ((int, str, str), (int, str, str, dict) ), self.create)28 yield ('TICKET_APPEND', ((list, int, str), (list, int, str, dict) ), self.update)29 yield ('TICKET_CREATE', ((int, str, str), (int, str, str, dict), (int, str, str, dict, bool)), self.create) 30 yield ('TICKET_APPEND', ((list, int, str), (list, int, str, dict), (list, int, str, dict, bool)), self.update) 29 31 yield ('TICKET_ADMIN', ((None, int),), self.delete) 30 32 yield ('TICKET_VIEW', ((dict, int), (dict, int, int)), self.changeLog) 31 33 yield ('TICKET_VIEW', ((list, int),), self.listAttachments) … … 69 71 t = model.Ticket(self.env, id) 70 72 return (t.id, t.time_created, t.time_changed, t.values) 71 73 72 def create(self, req, summary, description, attributes = {} ):74 def create(self, req, summary, description, attributes = {}, notify=False): 73 75 """ Create a new ticket, returning the ticket ID. """ 74 76 t = model.Ticket(self.env) 75 77 t['status'] = 'new' … … 79 81 for k, v in attributes.iteritems(): 80 82 t[k] = v 81 83 t.insert() 84 85 if notify: 86 try: 87 tn = TicketNotifyEmail(self.env) 88 tn.notify(t, newticket=True) 89 except Exception, e: 90 self.log.exception("Failure sending notification on creation " 91 "of ticket #%s: %s" % (t.id, e)) 92 82 93 return t.id 83 94 84 def update(self, req, id, comment, attributes = {} ):95 def update(self, req, id, comment, attributes = {}, notify=False): 85 96 """ Update a ticket, returning the new ticket in the same form as getTicket(). """ 97 now = int(time.time()) 98 86 99 t = model.Ticket(self.env, id) 87 100 for k, v in attributes.iteritems(): 88 101 t[k] = v 89 102 t.save_changes(req.authname or 'anonymous', comment) 103 104 if notify: 105 try: 106 tn = TicketNotifyEmail(self.env) 107 tn.notify(t, newticket=False, modtime=now) 108 except Exception, e: 109 self.log.exception("Failure sending notification on change of " 110 "ticket #%s: %s" % (t.id, e)) 111 90 112 return self.get(req, t.id) 91 113 92 114 def delete(self, req, id):
