Ticket #7758: ticket_notifcation.diff
| File ticket_notifcation.diff, 3.4 KB (added by dbytesguard-trackhacks@…, 4 years ago) |
|---|
-
Trac-0.11.1/trac/ticket/web_ui.py
956 956 ticket.insert() 957 957 req.perm(ticket.resource).require('TICKET_VIEW') 958 958 959 # Notify960 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 967 959 # Redirect the user to the newly created ticket or add attachment 968 960 if 'attachment' in req.args: 969 961 req.redirect(req.href.attachment('ticket', ticket.id, … … 984 976 # -- Save changes 985 977 986 978 now = datetime.now(utc) 987 ifticket.save_changes(get_reporter_id(req, 'author'),979 ticket.save_changes(get_reporter_id(req, 'author'), 988 980 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) 996 982 997 983 # After saving the changes, apply the side-effects. 998 984 for controller in controllers: -
Trac-0.11.1/trac/ticket/notification.py
19 19 from trac import __version__ 20 20 from trac.core import * 21 21 from trac.config import * 22 from trac.ticket.api import ITicketChangeListener 22 23 from trac.notification import NotifyEmail 23 24 from trac.util import md5 24 25 from trac.util.datefmt import to_timestamp … … 26 27 27 28 from genshi.template.text import TextTemplate 28 29 30 class TicketNotifyEmail: pass 31 29 32 class TicketNotificationSystem(Component): 33 implements(ITicketChangeListener) 30 34 31 35 always_notify_owner = BoolOption('notification', 'always_notify_owner', 32 36 'false', … … 48 52 (since 0.11)""") 49 53 50 54 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 51 74 class TicketNotifyEmail(NotifyEmail): 52 75 """Notification of ticket changes.""" 53 76
