Ticket #1383: improved_notifications_6233.diff

File improved_notifications_6233.diff, 2.4 KB (added by nielx, 16 years ago)

Patch against trac rev 6233

  • trac/ticket/notification.py

     
    7575        change_data = {}
    7676        link = self.env.abs_href.ticket(ticket.id)
    7777        summary = self.ticket['summary']
     78        author = ''
    7879       
    7980        if not self.newticket and modtime:  # Ticket change
    8081            from trac.ticket.web_ui import TicketModule
     
    8889                                    CRLF)
    8990                    })
    9091                link += '#comment:%s' % str(change.get('cnum', ''))
     92                author = change['author']
    9193                for field, values in change['fields'].iteritems():
    9294                    old = values['old']
    9395                    new = values['new']
     
    127129                        changes_body += '  * %s:  %s%s' % (field, chg, CRLF)
    128130                    if newv:
    129131                        change_data[field] = {'oldvalue': old, 'newvalue': new}
     132
     133        if self.newticket:
     134            author = ticket["reporter"]
    130135           
    131136        self.ticket['description'] = wrap(
    132137            self.ticket.values.get('description', ''), self.COLS,
     
    146151            'changes_descr': changes_descr,
    147152            'change': change_data
    148153            })
    149         NotifyEmail.notify(self, ticket.id, subject)
     154        NotifyEmail.notify(self, ticket.id, subject, author)
    150155
    151156    def format_props(self):
    152157        tkt = self.ticket
  • trac/notification.py

     
    213213        else:
    214214            raise TracError(_('Invalid email encoding setting: %s' % pref))
    215215
    216     def notify(self, resid, subject):
     216    def notify(self, resid, subject, from_name=None):
    217217        self.subject = subject
    218218
    219219        if not self.config.getbool('notification', 'smtp_enabled'):
     
    231231                                        ' nor ', tag.b('notification.reply_to'),
    232232                                        'are specified in the configuration.')),
    233233                              'SMTP Notification Error')
     234        if not self.from_name:
     235            self.from_name = from_name
    234236
    235237        # Authentication info (optional)
    236238        self.user_name = self.config['notification'].get('smtp_user')