From 35c7265bffa617aa2c39a45123445d185fb862e2 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Mon, 3 Apr 2017 17:06:06 +0000 Subject: [PATCH] Fixed send email template --- .../contrib/bills/templates/bills/bill-notification.email | 4 ++-- orchestra/utils/mail.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/orchestra/contrib/bills/templates/bills/bill-notification.email b/orchestra/contrib/bills/templates/bills/bill-notification.email index 10bbbcdc..7a00022a 100644 --- a/orchestra/contrib/bills/templates/bills/bill-notification.email +++ b/orchestra/contrib/bills/templates/bills/bill-notification.email @@ -1,5 +1,5 @@ -{% if subject %}Bill {{ bill.number }}{% endif %} -{% if message %}Dear {{ bill.account.username }}, +{% if email_part == 'subject' %}Bill {{ bill.number }}{% endif %} +{% if email_part == 'message' %}Dear {{ bill.account.username }}, Find your {{ bill.get_type_display.lower }} attached. If you have any question, please write us at support@orchestra.lan diff --git a/orchestra/utils/mail.py b/orchestra/utils/mail.py index c159ee03..caa4589e 100644 --- a/orchestra/utils/mail.py +++ b/orchestra/utils/mail.py @@ -24,8 +24,10 @@ def render_email_template(template, context): 'scheme': url.scheme, 'domain': url.netloc, } - subject = render_to_string(template, {'subject': True}, context).strip() - message = render_to_string(template, {'message': True}, context).strip() + context['email_part'] = 'subject' + subject = render_to_string(template, context).strip() + context['email_part'] = 'message' + message = render_to_string(template, context).strip() return subject, message