Commit 8928ce94 authored by Michal Čihař's avatar Michal Čihař

Simplify templates rendering

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 11ea1383
......@@ -199,10 +199,10 @@ def send_notification_email(language, email, notification,
if language is not None:
django_translation.activate(language)
# Template names
subject_template = 'mail/{}_subject.txt'.format(notification)
body_template = 'mail/{}.txt'.format(notification)
html_body_template = 'mail/{}.html'.format(notification)
# Template name
context['subject_template'] = 'mail/{}_subject.txt'.format(
notification
)
# Adjust context
context['current_site_url'] = get_site_url()
......@@ -211,15 +211,23 @@ def send_notification_email(language, email, notification,
context['translation_url'] = get_site_url(
translation_obj.get_absolute_url()
)
context['subject_template'] = subject_template
context['site_title'] = SITE_TITLE
# Render subject
subject = render_to_string(subject_template, context).strip()
subject = render_to_string(
context['subject_template'],
context
).strip()
# Render body
body = render_to_string(body_template, context)
html_body = render_to_string(html_body_template, context)
body = render_to_string(
'mail/{}.txt'.format(notification),
context
)
html_body = render_to_string(
'mail/{}.html'.format(notification),
context
)
# Define headers
headers['Auto-Submitted'] = 'auto-generated'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment