Changeset 1950

Show
Ignore:
Timestamp:
02/11/07 07:18:24 (1 year ago)
Author:
athomas
Message:

XmlRpcPlugin:

Send ticket notifications when. Thanks to stp for the patch. Closes #1069.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • xmlrpcplugin/0.10/tracrpc/api.py

    r1278 r1950  
    225225        indicate API breaking changes, while minor version changes are simple 
    226226        additions, bug fixes, etc. """ 
    227         return [0, 1
     227        return [0, 2
  • xmlrpcplugin/0.10/tracrpc/ticket.py

    r1732 r1950  
    66import trac.ticket.query as query 
    77from trac.ticket.api import TicketSystem 
    8  
     8from trac.ticket.notification import TicketNotifyEmail 
     9 
     10import time 
    911import pydoc 
    1012import xmlrpclib 
     
    2527        yield ('TICKET_VIEW', ((list, int),), self.getAvailableActions) 
    2628        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) 
    2931        yield ('TICKET_ADMIN', ((None, int),), self.delete) 
    3032        yield ('TICKET_VIEW', ((dict, int), (dict, int, int)), self.changeLog) 
     
    7072        return (t.id, t.time_created, t.time_changed, t.values) 
    7173 
    72     def create(self, req, summary, description, attributes = {}): 
     74    def create(self, req, summary, description, attributes = {}, notify=False): 
    7375        """ Create a new ticket, returning the ticket ID. """ 
    7476        t = model.Ticket(self.env) 
     
    8082            t[k] = v 
    8183        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                 
    8293        return t.id 
    8394 
    84     def update(self, req, id, comment, attributes = {}): 
     95    def update(self, req, id, comment, attributes = {}, notify=False): 
    8596        """ Update a ticket, returning the new ticket in the same form as getTicket(). """ 
     97        now = int(time.time()) 
     98 
    8699        t = model.Ticket(self.env, id) 
    87100        for k, v in attributes.iteritems(): 
    88101            t[k] = v 
    89102        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 
    90112        return self.get(req, t.id) 
    91113