Edgewall Software

Ticket #7758: ticket_notifcation.diff

File ticket_notifcation.diff, 3.4 KB (added by dbytesguard-trackhacks@…, 4 years ago)

Proposed Change

  • Trac-0.11.1/trac/ticket/web_ui.py

     
    956956        ticket.insert() 
    957957        req.perm(ticket.resource).require('TICKET_VIEW') 
    958958 
    959         # Notify 
    960         try: 
    961             tn = TicketNotifyEmail(self.env) 
    962             tn.notify(ticket, newticket=True) 
    963         except Exception, e: 
    964             self.log.exception("Failure sending notification on creation of " 
    965                                "ticket #%s: %s" % (ticket.id, e)) 
    966  
    967959        # Redirect the user to the newly created ticket or add attachment 
    968960        if 'attachment' in req.args: 
    969961            req.redirect(req.href.attachment('ticket', ticket.id, 
     
    984976        # -- Save changes 
    985977 
    986978        now = datetime.now(utc) 
    987         if ticket.save_changes(get_reporter_id(req, 'author'), 
     979        ticket.save_changes(get_reporter_id(req, 'author'), 
    988980                                     req.args.get('comment'), when=now, 
    989                                      cnum=internal_cnum): 
    990             try: 
    991                 tn = TicketNotifyEmail(self.env) 
    992                 tn.notify(ticket, newticket=False, modtime=now) 
    993             except Exception, e: 
    994                 self.log.exception("Failure sending notification on change to " 
    995                                    "ticket #%s: %s" % (ticket.id, e)) 
     981                                     cnum=internal_cnum) 
    996982 
    997983        # After saving the changes, apply the side-effects. 
    998984        for controller in controllers: 
  • Trac-0.11.1/trac/ticket/notification.py

     
    1919from trac import __version__ 
    2020from trac.core import * 
    2121from trac.config import * 
     22from trac.ticket.api import ITicketChangeListener 
    2223from trac.notification import NotifyEmail 
    2324from trac.util import md5 
    2425from trac.util.datefmt import to_timestamp 
     
    2627 
    2728from genshi.template.text import TextTemplate 
    2829 
     30class TicketNotifyEmail: pass 
     31 
    2932class TicketNotificationSystem(Component): 
     33    implements(ITicketChangeListener) 
    3034 
    3135    always_notify_owner = BoolOption('notification', 'always_notify_owner', 
    3236                                     'false', 
     
    4852        (since 0.11)""") 
    4953 
    5054 
     55    def ticket_created(self, ticket): 
     56        try: 
     57            tn = TicketNotifyEmail(self.env) 
     58            tn.notify(ticket, newticket=True) 
     59        except Exception, e: 
     60            self.log.exception("Failure sending notification on creation to " 
     61                              "ticket #%s: %s" % (ticket.id, e)) 
     62 
     63    def ticket_changed(self, ticket, comment, author, old_values): 
     64        try: 
     65            tn = TicketNotifyEmail(self.env) 
     66            tn.notify(ticket, newticket=False, modtime=ticket.time_changed) 
     67        except Exception, e: 
     68            self.log.exception("Failure sending notification on change to " 
     69                              "ticket #%s: %s" % (ticket.id, e)) 
     70 
     71    def ticket_deleted(self, ticket):     
     72        """Not implemented for email notificaitons""" 
     73 
    5174class TicketNotifyEmail(NotifyEmail): 
    5275    """Notification of ticket changes.""" 
    5376