From 339467bd6bc45755963821d6b10073c8fc7724f1 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sat, 17 Sep 2016 08:31:44 +0200 Subject: [PATCH] Clean linebreaks and style in html email --- scipost/utils.py | 6 +++--- scipost/views.py | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scipost/utils.py b/scipost/utils.py index 9e1445e51..f7d40a071 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -12,7 +12,7 @@ from .models import * EMAIL_FOOTER = ( '{% load staticfiles %}' - '<ul style="background-color: #f0f0f0; color: #002B49; list-style-type: none;">' + '<ul style="background-color: #f0f0f0; color: #002B49; list-style-type: none; padding: 0px 5px;">' '<li style="display: inline; margin: 0px; padding: 0px;"><a href="https://scipost.org">' '<img src="{% static \'scipost/images/logo_scipost_with_bgd_small.jpg\' %}"></a></li>' '<li style="display: inline; margin: 5px; padding: 5px;">' @@ -29,12 +29,12 @@ EMAIL_FOOTER = ( ) EMAIL_UNSUBSCRIBE_LINK_PLAIN = ( - '\n\nIf you do not with to receive our emails, you can unsubscribe by ' + '\n\nUnsubscribe by ' 'updating your personal data at https://scipost.org/update_personal_data.' ) EMAIL_UNSUBSCRIBE_LINK = ( - '\n\n<p>If you do not with to receive our emails, you can unsubscribe by ' + '\n\n<p style="font-size: 8px;">Unsubscribe by ' '<a href="https://scipost.org/update_personal_data">updating your personal data</a>.</p>' ) diff --git a/scipost/views.py b/scipost/views.py index 9a2176f4e..6b491d822 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -941,12 +941,14 @@ def email_group_members(request): + form.cleaned_data['email_text'] + EMAIL_UNSUBSCRIBE_LINK_PLAIN) html_template = Template( - 'Dear ' + title_dict[member.contributor.title] + ' ' + - member.last_name + ', \n\n' - + form.cleaned_data['email_text'] - + '\n\n\n' + EMAIL_FOOTER + EMAIL_UNSUBSCRIBE_LINK + 'Dear {{ title }} ' + + member.last_name + ', \n\n{{ email_text|linebreaks }}' + + '\n\n' + EMAIL_FOOTER + EMAIL_UNSUBSCRIBE_LINK ) - context = Context({}) + context = Context( + {'title': title_dict[member.contributor.title], + 'email_text': form.cleaned_data['email_text'], + }) html_version = html_template.render(context) # mail.EmailMessage(form.cleaned_data['email_subject'], # email_text, 'SciPost Admin <admin@scipost.org>', -- GitLab