From: Stephen Finucane Date: Wed, 6 Jun 2018 14:31:33 +0000 (+0100) Subject: templates: Move mails to separate directory X-Git-Tag: v2.2.0-rc1~271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f2adb19ec0cd5ef7508e5b01589af8af75d301a;p=thirdparty%2Fpatchwork.git templates: Move mails to separate directory This makes things a little easier to parse. A couple of templates are renamed and the 'register.mail' template, which appears to be unused since commit f1e089f7, is removed. Signed-off-by: Stephen Finucane --- diff --git a/patchwork/notifications.py b/patchwork/notifications.py index 3922fafa..7be30f0a 100644 --- a/patchwork/notifications.py +++ b/patchwork/notifications.py @@ -63,10 +63,11 @@ def send_notifications(): } subject = render_to_string( - 'patchwork/patch-change-notification-subject.text', + 'patchwork/mails/patch-change-notification-subject.txt', context).strip() - content = render_to_string('patchwork/patch-change-notification.mail', - context) + content = render_to_string( + 'patchwork/mails/patch-change-notification.txt', + context) message = EmailMessage(subject=subject, body=content, from_email=settings.NOTIFICATION_FROM_EMAIL, diff --git a/patchwork/templates/patchwork/activation_email_subject.txt b/patchwork/templates/patchwork/mails/activation-subject.txt similarity index 100% rename from patchwork/templates/patchwork/activation_email_subject.txt rename to patchwork/templates/patchwork/mails/activation-subject.txt diff --git a/patchwork/templates/patchwork/activation_email.txt b/patchwork/templates/patchwork/mails/activation.txt similarity index 100% rename from patchwork/templates/patchwork/activation_email.txt rename to patchwork/templates/patchwork/mails/activation.txt diff --git a/patchwork/templates/patchwork/optin-request.mail b/patchwork/templates/patchwork/mails/optin-request.txt similarity index 100% rename from patchwork/templates/patchwork/optin-request.mail rename to patchwork/templates/patchwork/mails/optin-request.txt diff --git a/patchwork/templates/patchwork/optout-request.mail b/patchwork/templates/patchwork/mails/optout-request.txt similarity index 100% rename from patchwork/templates/patchwork/optout-request.mail rename to patchwork/templates/patchwork/mails/optout-request.txt diff --git a/patchwork/templates/patchwork/patch-change-notification-subject.text b/patchwork/templates/patchwork/mails/patch-change-notification-subject.txt similarity index 100% rename from patchwork/templates/patchwork/patch-change-notification-subject.text rename to patchwork/templates/patchwork/mails/patch-change-notification-subject.txt diff --git a/patchwork/templates/patchwork/patch-change-notification.mail b/patchwork/templates/patchwork/mails/patch-change-notification.txt similarity index 100% rename from patchwork/templates/patchwork/patch-change-notification.mail rename to patchwork/templates/patchwork/mails/patch-change-notification.txt diff --git a/patchwork/templates/patchwork/user-link.mail b/patchwork/templates/patchwork/mails/user-link.txt similarity index 100% rename from patchwork/templates/patchwork/user-link.mail rename to patchwork/templates/patchwork/mails/user-link.txt diff --git a/patchwork/templates/patchwork/register.mail b/patchwork/templates/patchwork/register.mail deleted file mode 100644 index 51f3adfa..00000000 --- a/patchwork/templates/patchwork/register.mail +++ /dev/null @@ -1,11 +0,0 @@ -Hi, - -This email is to confirm your account on the Patchwork patch-tracking -system. You can activate your account by visiting the url: - - http://{{site.domain}}{% url 'registration_activateactivation_key'=request.key %} - -If you didn't request a user account on Patchwork, then you can ignore -this mail. - -Happy patchworking. diff --git a/patchwork/views/mail.py b/patchwork/views/mail.py index 49aa27ee..f6bdbb47 100644 --- a/patchwork/views/mail.py +++ b/patchwork/views/mail.py @@ -69,7 +69,7 @@ def optin_confirm(request, conf): def _optinout(request, action, description): context = {} - mail_template = 'patchwork/%s-request.mail' % action + mail_template = 'patchwork/mails/%s-request.txt' % action html_template = 'patchwork/%s-request.html' % action if request.method != 'POST': diff --git a/patchwork/views/user.py b/patchwork/views/user.py index 36cd4b9d..838a1abc 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -52,11 +52,13 @@ def register(request): conf.save() # send email - subject = 'Patchwork account confirmation' + subject = render_to_string( + 'patchwork/mails/activation-subject.txt') message = render_to_string( - 'patchwork/activation_email.txt', + 'patchwork/mails/activation.txt', {'site': Site.objects.get_current(), 'confirmation': conf}) + # TODO(stephenfin): Should this be surrounded by a try-except? send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [conf.email]) @@ -136,10 +138,12 @@ def link(request): context['confirmation'] = conf + subject = 'Patchwork email address confirmation', + message = render_to_string('patchwork/mails/user-link.txt', + context, request=request) try: - send_mail('Patchwork email address confirmation', - render_to_string('patchwork/user-link.mail', - context, request=request), + send_mail(subject, + message, settings.DEFAULT_FROM_EMAIL, [form.cleaned_data['email']]) except smtplib.SMTPException: