Edgewall Software

Ticket #2259: trac_ticket_r6106.patch

File trac_ticket_r6106.patch, 1.4 KB (added by sid, 17 years ago)

Update previous submissions to be in line with changes in trunk

  • trac/attachment.py

     
    3333from trac.env import IEnvironmentSetupParticipant
    3434from trac.perm import PermissionError, PermissionSystem, IPermissionPolicy
    3535from trac.mimeview import *
     36from trac.ticket import Ticket
     37from trac.ticket.notification import TicketNotifyEmail
    3638from trac.timeline.api import TimelineEvent
    3739from trac.util import get_reporter_id, create_unique_file, content_disposition
    3840from trac.util.datefmt import to_timestamp, utc
     
    551553                pass # don't worry if there's nothing to replace
    552554            attachment.filename = None
    553555        attachment.insert(filename, upload.file, size)
     556        if attachment.parent_realm == 'ticket':
     557            try:
     558                tn = TicketNotifyEmail(self.env)
     559                # have to get the ticket that the attachment will modify
     560                ticket = Ticket(self.env, tkt_id=attachment.parent_id)
     561                tn.notify(ticket, newticket=False, modtime=attachment.time)
     562            except Exception, e:
     563                self.log.exception("Failure sending notification for attachment "
     564                                   "on ticket #%s: %s" % (ticket.id, e))
    554565
    555566        # Redirect the user to list of attachments (must add a trailing '/')
    556567        req.redirect(context.resource_href('..') + '/')