Edgewall Software

Ticket #2259: add-attachment-description.diff

File add-attachment-description.diff, 1.9 KB (added by cboos, 12 months ago)

Also send attachment's description in the body of the notificatio n mail. Applies on top of attachment_0.13dev.2.patch.

  • trac/ticket/notification.py

    # HG changeset patch
    # Parent d09d67a750ae89b79586afbcac4a3f43777a5757
    Also send attachment's description in the body of the notification mail. Applies on top of [attachment:attachment_0.13dev.2.patch].
    
    diff -r d09d67a750ae -r 218983e06837 trac/ticket/notification.py
    a b class TicketNotifyEmail(NotifyEmail): 
    137137            ticket.fields = translated_fields 
    138138            reactivate(t) 
    139139 
    140     def notify_attachment(self, ticket, author, filename, modtime, add): 
     140    def notify_attachment(self, ticket, author, filename, modtime, body): 
    141141        """Send ticket attachment notification (untranslated)""" 
    142142        t = deactivate() 
    143143        translated_fields = ticket.fields 
    class TicketNotifyEmail(NotifyEmail): 
    159159            ticket_values['new'] = self.newticket 
    160160            ticket_values['link'] = link 
    161161            subject = 'Re: ' + self.format_subj(summary) 
    162             body = '%s attachment "%s"' % (add and 'Add' or 'Delete', filename) 
    163162            author = obfuscate_email_address(author) 
    164             change = { 'author': author } 
     163            change = {'author': author} 
    165164            self.data.update({ 
    166165                'ticket_props': self.format_props(), 
    167166                'ticket_body_hdr': self.format_hdr(), 
    class TicketAttachmentNotifier(Component 
    492491        tn = TicketNotifyEmail(self.env) 
    493492        filename = attachment.filename 
    494493        date = attachment.date or datetime.now(utc) 
    495         tn.notify_attachment(ticket, author, filename, date, add) 
     494        # Note: no translation yet 
     495        if add: 
     496            body = "Attachment \"%s\" added." % filename 
     497        else: 
     498            body = "Attachment \"%s\" removed." % filename 
     499        if attachment.description: 
     500            body += "\n\n" + attachment.description 
     501        tn.notify_attachment(ticket, author, filename, date, body)