Mailing List Archive

ticket_notify_email.txt for Jinja2
I'm working on a new template for Jinja2 to get a better result on MS
Outlook:

https://trac.edgewall.org/wiki/CookBook/Notification/Templates#jinja2
With this template I wonder, why I get the following output for user name
"Foo Bar":

--------------------------------------------------------------------------
Reporter: Foo
Owner: Foo Bar
...
--------------------------------------------------------------------------

Why gives Reporter and Owner different output formats?

While learning how to write a Jinja2 template, I read
https://trac.edgewall.org/wiki/TracNotification#Customizingtheemailsubject
There only a Genshi documentation is linked. The code snippet below also
looks like Genshi. Could it be that the wiki needs an update to match the
Trac-1.4 version?

Best regards,
- Mo

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/96a7354b-7c6a-427e-8333-11127c7bc164%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Fri, Nov 22, 2019 at 9:37 PM Mo <burcheri.massimo@gmail.com> wrote:
>
> I'm working on a new template for Jinja2 to get a better result on MS Outlook:
>
> https://trac.edgewall.org/wiki/CookBook/Notification/Templates#jinja2
> With this template I wonder, why I get the following output for user name "Foo Bar":
>
> --------------------------------------------------------------------------
> Reporter: Foo
> Owner: Foo Bar
> ...
> --------------------------------------------------------------------------
>
> Why gives Reporter and Owner different output formats?

Since Trac 1.2, username in the fields is displayed using full name of the user.
If you don't want the feature, set disable to [trac] show_full_names option.

See https://trac.edgewall.org/ticket/7339.

--
Jun Omae <jun66j5@gmail.com> (?? ?)

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMahxw59GsL11AKr27jDeU_9BTs%2BtAvJDH1WokRFD6dBFLA%40mail.gmail.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
Am Montag, 25. November 2019 04:28:39 UTC+1 schrieb Jun Omae:

> Since Trac 1.2, username in the fields is displayed using full name of the
> user.
> If you don't want the feature, set disable to [trac] show_full_names
> option.
>
> See https://trac.edgewall.org/ticket/7339.
>

So why doesn't this option apply to both fields Reporter and Owner?

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/90987f4f-fcde-41d0-b2dc-7b56af601f02%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Mon, Nov 25, 2019 at 3:07 AM Mo <burcheri.massimo@gmail.com> wrote:

>
> Am Montag, 25. November 2019 04:28:39 UTC+1 schrieb Jun Omae:
>
>> Since Trac 1.2, username in the fields is displayed using full name of
>> the user.
>> If you don't want the feature, set disable to [trac] show_full_names
>> option.
>>
>> See https://trac.edgewall.org/ticket/7339.
>>
>
> So why doesn't this option apply to both fields Reporter and Owner?
>

In your example, are owner and reporter the same user? I would check first
if "Foo" has a full name set in preferences. The fallback is to use
username when full name is not set.

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CA%2BBGpn_Rvo%3DFLruwUgfu8HFV6cBjKdUdq4mVfD7HkMUbN5xFPw%40mail.gmail.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
Am Montag, 25. November 2019 16:41:35 UTC+1 schrieb RjOllos:
>
>
> In your example, are owner and reporter the same user? I would check first
> if "Foo" has a full name set in preferences. The fallback is to use
> username when full name is not set.
>

In my example, the owner and reporter is the same user. The account has
full name set. show_full_names = enabled is set in the trac.ini. But the
fullname in this notification template is only used for the owner, while
reporter has the shortname.

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/c4a16c34-619f-40eb-87e9-2dd567ed4239%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Thu, Nov 28, 2019 at 6:50 PM Mo <burcheri.massimo@gmail.com> wrote:
>
> Am Montag, 25. November 2019 16:41:35 UTC+1 schrieb RjOllos:
>>
>> In your example, are owner and reporter the same user? I would check first if "Foo" has a full name set in preferences. The fallback is to use username when full name is not set.
>
> In my example, the owner and reporter is the same user. The account has full name set. show_full_names = enabled is set in the trac.ini. But the fullname in this notification template is only used for the owner, while reporter has the shortname.

First, please confirm email of ticket notification without custom template.
By the results, we will be able to find where root cause exists.

Also, I assume the report's value probably is wrapped. When value of
the field is wrapped,
example in https://trac.edgewall.org/wiki/CookBook/Notification/Templates
wouldn't work.

--
Jun Omae <jun66j5@gmail.com> (?? ?)

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMajS5hAcaqzDmv9SjQ%3D7L0ai_kejgZikjWDMhfQNzd8YTQ%40mail.gmail.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Trac-1.4 I followed
https://trac.edgewall.org/wiki/CookBook/Notification/Templates#jinja2

and have a $PROJECT_ENV/templates/ticket_notify_email.txt like this:

${ticket_body_hdr}
# set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
'Component', 'Severity', 'Resolution', 'Keywords')
# for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
# set a = a.split(':', 1)|map('trim')|list
# if len(a) > 1 and a[0] in sel:
${'%-*s %s'|format(12, a[0] + ':', a[1])}
# endif
# endfor
# if ticket.new:
${ticket.description}
# else:
# if changes_body:
${_('Changes (by %(author)s):', author=change.author)}

${changes_body}
# endif
# if changes_descr:
# if not changes_body and not change.comment and change.author:
${_('Description changed by %(author)s:', author=change.author)}
# endif
${changes_descr}
--
# endif
# if change.comment:

${_('Comment:') if changes_body else
_('Comment (by %(author)s):', author=change.author)}

${change.comment}
# endif
# endif
${'-- '}
${_('Ticket URL: <%(link)s>', link=ticket.link)}
${project.name} <${project.url or abs_href()}>
${project.descr}

which is almost the default template with *${ticket_props}* replaced by

# set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
'Component', 'Severity', 'Resolution', 'Keywords')
# for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
# set a = a.split(':', 1)|map('trim')|list
# if len(a) > 1 and a[0] in sel:
${'%-*s %s'|format(12, a[0] + ':', a[1])}
# endif
# endfor

But is has no effect. Is the file and location correct? I also deployed by trac-admin, not sure if required.

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/ac0deaeb-7474-473a-9dda-c4acb9df79e3%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
First, please share ticket notification mail without custom template.

On Wed, Jan 15, 2020 at 22:53 Mo <burcheri.massimo@gmail.com> wrote:

> On Trac-1.4 I followed
> https://trac.edgewall.org/wiki/CookBook/Notification/Templates#jinja2
>
> and have a $PROJECT_ENV/templates/ticket_notify_email.txt like this:
>
> ${ticket_body_hdr}
> # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority',
> 'Milestone',
> 'Component', 'Severity', 'Resolution', 'Keywords')
> # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
> # set a = a.split(':', 1)|map('trim')|list
> # if len(a) > 1 and a[0] in sel:
> ${'%-*s %s'|format(12, a[0] + ':', a[1])}
> # endif
> # endfor
> # if ticket.new:
> ${ticket.description}
> # else:
> # if changes_body:
> ${_('Changes (by %(author)s):', author=change.author)}
>
> ${changes_body}
> # endif
> # if changes_descr:
> # if not changes_body and not change.comment and change.author:
> ${_('Description changed by %(author)s:', author=change.author)}
> # endif
> ${changes_descr}
> --
> # endif
> # if change.comment:
>
> ${_('Comment:') if changes_body else
> _('Comment (by %(author)s):', author=change.author)}
>
> ${change.comment}
> # endif
> # endif
> ${'-- '}
> ${_('Ticket URL: <%(link)s>', link=ticket.link)}
> ${project.name} <${project.url or abs_href()}>
> ${project.descr}
>
> which is almost the default template with *${ticket_props}* replaced by
>
> # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
> 'Component', 'Severity', 'Resolution', 'Keywords')
> # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
> # set a = a.split(':', 1)|map('trim')|list
> # if len(a) > 1 and a[0] in sel:
> ${'%-*s %s'|format(12, a[0] + ':', a[1])}
> # endif
> # endfor
>
> But is has no effect. Is the file and location correct? I also deployed by trac-admin, not sure if required.
>
> --
> 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 trac-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/trac-users/ac0deaeb-7474-473a-9dda-c4acb9df79e3%40googlegroups.com
> <https://groups.google.com/d/msgid/trac-users/ac0deaeb-7474-473a-9dda-c4acb9df79e3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Jun Omae <jun66j5@gmail.com> (?? ?)

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMai0uYvN%3DLHRfFgP%2Bt687FXr4WdwVbU1bh98hfaKS0A5jQ%40mail.gmail.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
@Mo, did you figure out where the ticket_notify_email.txt is supposed to be
to allow modifications?

On Wednesday, January 15, 2020 at 8:53:04 AM UTC-5 Mo wrote:

> On Trac-1.4 I followed
> https://trac.edgewall.org/wiki/CookBook/Notification/Templates#jinja2
>
> and have a $PROJECT_ENV/templates/ticket_notify_email.txt like this:
>
> ${ticket_body_hdr}
> # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority',
> 'Milestone',
> 'Component', 'Severity', 'Resolution', 'Keywords')
> # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
> # set a = a.split(':', 1)|map('trim')|list
> # if len(a) > 1 and a[0] in sel:
> ${'%-*s %s'|format(12, a[0] + ':', a[1])}
> # endif
> # endfor
> # if ticket.new:
> ${ticket.description}
> # else:
> # if changes_body:
> ${_('Changes (by %(author)s):', author=change.author)}
>
> ${changes_body}
> # endif
> # if changes_descr:
> # if not changes_body and not change.comment and change.author:
> ${_('Description changed by %(author)s:', author=change.author)}
> # endif
> ${changes_descr}
> --
> # endif
> # if change.comment:
>
> ${_('Comment:') if changes_body else
> _('Comment (by %(author)s):', author=change.author)}
>
> ${change.comment}
> # endif
> # endif
> ${'-- '}
> ${_('Ticket URL: <%(link)s>', link=ticket.link)}
> ${project.name} <${project.url or abs_href()}>
> ${project.descr}
>
> which is almost the default template with *${ticket_props}* replaced by
>
> # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone',
> 'Component', 'Severity', 'Resolution', 'Keywords')
> # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
> # set a = a.split(':', 1)|map('trim')|list
> # if len(a) > 1 and a[0] in sel:
> ${'%-*s %s'|format(12, a[0] + ':', a[1])}
> # endif
> # endfor
>
> But is has no effect. Is the file and location correct? I also deployed by trac-admin, not sure if required.
>
>

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/72461ab3-ede9-4292-975f-ad306baf5d5fn%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Friday, April 16, 2021 at 2:29:49 PM UTC-7 steel...@raidoh.com wrote:

> @Mo, did you figure out where the ticket_notify_email.txt is supposed to
> be to allow modifications?
>

The template should be in $env/templates, but there are other options as
well if you want to share the template among environments:
https://trac.edgewall.org/wiki/TracNotification#CustomizingContent


This section https://trac.edgewall.org/wiki/TracIni#GlobalConfiguration has
details:

There are three more options in the [inherit] section, templates_dir for
sharing global templates, htdocs_dir for sharing global htdocs and
plugins_dir, for sharing plugins. Those options can be specified in the
shared configuration file, and in fact, configuration files can even be
chained if you specify another [inherit] file there.

Note that the templates found in the templates/ directory of the
TracEnvironment have precedence over those found in [inherit]
templates_dir. In turn, the latter have precedence over the installed
templates, so be careful about what you put there. Notably, if you override
a default template, refresh your modifications when you upgrade to a new
version of Trac. The preferred way to perform TracInterfaceCustomization is
to write a custom plugin doing an appropriate ITemplateStreamFilter
transformation.

Ryan

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/cbaa6c4e-f6a3-4fd4-b91f-8a06f3247e42n%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
Hi Ryan,
Thanks for the response, but I don't think that's the issue. I'd put
ticket_notify_email.txt in $ENV/templates and the file and templates
directory are both the same permissions as the rest of the files. I'm only
working with a single environment. I'd added the directories under
[inherit] before I realized they were for this purpose, but removing them
didn't make any change. So far, I've only replaced the 2nd line per the
Jinja2 instructions and swapped the Target URL to the bottom of the footer
to check whether it's functioning as expected, but the emails all show up
the same. Is there a .py file in the dist-package/trac directory I can look
at to check where it's looking?
Here's my txt file,/var/lib/trac/projects/ticket_notify_email.txt
${ticket_body_hdr}
--------------------------------------------------------------------------
#set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority',
'Milestone','Component', 'Severity', 'Resolution', 'Keywords')
#for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'):
# set a = a.split(':', 1)|map('trim')|list
# if len(a) > 1 and a[0] in sel:
${'%-*s %s'|format(12, a[0] + ':', a[1])}
# endif
#endfor
--------------------------------------------------------------------------
# if ticket.new:
${ticket.description}
# else:
# if changes_body:
${_('Changes (by %(author)s):', author=change.author)}

${changes_body}
# endif
# if changes_descr:
# if not changes_body and not change.comment and change.author:
${_('Description changed by %(author)s:', author=change.author)}
# endif
${changes_descr}
--
# endif
# if change.comment:

${_('Comment:') if changes_body else
_('Comment (by %(author)s):', author=change.author)}

${change.comment}
# endif
# endif
${'-- '}
${project.name} <${project.url or abs_href()}>
${project.descr}
${_('Ticket URL: <%(link)s>', link=ticket.link)}

On Friday, April 16, 2021 at 5:47:24 PM UTC-4 RjOllos wrote:

> On Friday, April 16, 2021 at 2:29:49 PM UTC-7 steel...@raidoh.com wrote:
>
>> @Mo, did you figure out where the ticket_notify_email.txt is supposed to
>> be to allow modifications?
>>
>
> The template should be in $env/templates, but there are other options as
> well if you want to share the template among environments:
> https://trac.edgewall.org/wiki/TracNotification#CustomizingContent
>
>
> This section https://trac.edgewall.org/wiki/TracIni#GlobalConfiguration
> has details:
>
> There are three more options in the [inherit] section, templates_dir for
> sharing global templates, htdocs_dir for sharing global htdocs and
> plugins_dir, for sharing plugins. Those options can be specified in the
> shared configuration file, and in fact, configuration files can even be
> chained if you specify another [inherit] file there.
>
> Note that the templates found in the templates/ directory of the
> TracEnvironment have precedence over those found in [inherit]
> templates_dir. In turn, the latter have precedence over the installed
> templates, so be careful about what you put there. Notably, if you override
> a default template, refresh your modifications when you upgrade to a new
> version of Trac. The preferred way to perform TracInterfaceCustomization is
> to write a custom plugin doing an appropriate ITemplateStreamFilter
> transformation.
>
> Ryan
>

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/64e02c4a-eaf3-431f-b1fc-b9c2cf6f5a6an%40googlegroups.com.
Re: ticket_notify_email.txt for Jinja2 [ In reply to ]
On Monday, April 19, 2021 at 7:52:01 AM UTC-7 steel...@raidoh.com wrote:

> Hi Ryan,
> Thanks for the response, but I don't think that's the issue. I'd put
> ticket_notify_email.txt in $ENV/templates and the file and templates
> directory are both the same permissions as the rest of the files. I'm only
> working with a single environment. I'd added the directories under
> [inherit] before I realized they were for this purpose, but removing them
> didn't make any change. So far, I've only replaced the 2nd line per the
> Jinja2 instructions and swapped the Target URL to the bottom of the footer
> to check whether it's functioning as expected, but the emails all show up
> the same. Is there a .py file in the dist-package/trac directory I can look
> at to check where it's looking?
>

The templates are loaded by Chrome._load_jinja_template:
https://trac.edgewall.org/browser/tags/trac-1.4.2/trac/web/chrome.py#L1376

Ryan

--
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 trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/126b5baf-f566-4797-a49c-7dc5645d2df7n%40googlegroups.com.