On Thursday, October 3, 2013 7:35:06 AM UTC-7, ams wrote:
>
> I'm using Trac 1.0.1 with a slightly modified notification.py to allow 
> HTML in ticket notifications.   This part works great, but I'm not clear on 
> how to add additional ticket properties to notifications.   
>
> This snippet on the TracNotification page is taken from 
> ticket_notify_email.txt
>
> --------------------------------------------------------------------------
>> {% with
>>    pv = [(a[0].strip(), a[1].strip()) for a in [b.split(':') for b in
>>          [c.strip() for c in 
>>           ticket_props.replace('|', '\n').splitlines()[1:-1]] if ':' in 
>> b]];
>>    sel = ['Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone', 
>>           'Component', 'Severity', 'Resolution', 'Keywords'] %}\
>> ${'\n'.join('%s\t%s' % (format(p[0]+':', ' <12'), p[1]) for p in pv if 
>> p[0] in sel)}
>> {% end %}\
>> --------------------------------------------------------------------------
>
>
> This creates a "table" of ticket properties in notifications, but I'm not 
> seeing how to set additional variables.  I tried adding "Time" to the sel 
> array, but no dice.  I'd like to get the ticket Create Date listed in the 
> ticket data (along with Reporter, Owner, Type, ect).  
>

The `sel` array is just the labels. We also need to add `ticket.time` to 
the array of property values, `pv`, so join another list with the pv list: 
[('Created', format_datetime(ticket.time))].

The result is:

------------------------------
--------------------------------------------
Reporter:       anonymous
Owner:          somebody
Type:           enhancement
Status:         new
Priority:       critical
Milestone:      milestone4
Component:      component1
Resolution:
Keywords:
Created:        10/03/2013 09:47:15 PM
--------------------------------------------------------------------------


Here is the full snippet that you can use to replace $ticket_props, as 
described in (1):

--------------------------------------------------------------------------
{% with
   pv = [(a[0].strip(), a[1].strip()) for a in [b.split(':') for b in
         [c.strip() for c in
          ticket_props.replace('|', '\n').splitlines()[1:-1]] if ':' in b]] 
+ \
        [('Created', format_datetime(ticket.time))];
   sel = ['Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
          'Component', 'Severity', 'Resolution', 'Keywords', 'Created'] %}\
${'\n'.join('%s\t%s' % (format(p[0]+':', ' <12'), p[1]) for p in pv if p[0] 
in sel)}
{% end %}\
--------------------------------------------------------------------------


 (1) 
http://trac.edgewall.org/wiki/TracNotification#Customizinge-mailcontentforMSOutlook

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to