From patchwork Mon Sep 17 14:17:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DSsy3rgnz9sfR for ; Tue, 18 Sep 2018 00:19:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="q770nEVk"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DSsy0xpMzF2ZM for ; Tue, 18 Sep 2018 00:19:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="q770nEVk"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.6; helo=relay-direct6.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="q770nEVk"; dkim-atps=neutral Received: from relay-direct6.mxroute.com (relay-direct6.mxroute.com [185.234.75.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsN5bYTzF2Nm for ; Tue, 18 Sep 2018 00:18:32 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct6.mxroute.com (Postfix) with ESMTP id 4652B3F01C for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 29F9C3F3E0 for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ql4inz0k3Ld4kFMEVj8VSyTRFNfGFzEgGSPfny+SydE=; b=q770nEVkGRadI1LjSOnzemfwJt 0aD/ngAn5gc/dhz3A5pr9MPPVg6Ab+viufKEVsASpk4wknECVwbxXvxOK1VPWGBZcL4rHcReKl3mY 6oREqtv6BSD6YPEyNGQDLmJn5my0XqMcvSQ7imkciRUyHBtVrNLHaSOA/iL1jaguQid43FaTeasIV aJ4sCChw0X2Qp7IssfvTQpoXV1rHmmNIkBSCZ74AMUFvuYg+8l+jfBR8PIItoPX0X0gF3A0n+n+Yl Y153Gb1h0fZqsDmtXVWaAkFKwr1s+PunJSTWy3Yy0D6D7wQEHizNuEzQsO5Z8A+eL0+uU0Lb8Oowh YNElLhiA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 1/6] templates: Move mails to separate directory Date: Mon, 17 Sep 2018 15:17:45 +0100 Message-Id: <20180917141750.21508-1-stephen@that.guru> X-Mailer: git-send-email 2.17.1 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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 --- patchwork/notifications.py | 7 ++++--- .../activation-subject.txt} | 0 .../{activation_email.txt => mails/activation.txt} | 0 .../optin-request.txt} | 0 .../optout-request.txt} | 0 .../patch-change-notification-subject.txt} | 0 .../patch-change-notification.txt} | 0 .../{user-link.mail => mails/user-link.txt} | 0 patchwork/templates/patchwork/register.mail | 11 ----------- patchwork/views/mail.py | 2 +- patchwork/views/user.py | 14 +++++++++----- 11 files changed, 14 insertions(+), 20 deletions(-) rename patchwork/templates/patchwork/{activation_email_subject.txt => mails/activation-subject.txt} (100%) rename patchwork/templates/patchwork/{activation_email.txt => mails/activation.txt} (100%) rename patchwork/templates/patchwork/{optin-request.mail => mails/optin-request.txt} (100%) rename patchwork/templates/patchwork/{optout-request.mail => mails/optout-request.txt} (100%) rename patchwork/templates/patchwork/{patch-change-notification-subject.text => mails/patch-change-notification-subject.txt} (100%) rename patchwork/templates/patchwork/{patch-change-notification.mail => mails/patch-change-notification.txt} (100%) rename patchwork/templates/patchwork/{user-link.mail => mails/user-link.txt} (100%) delete mode 100644 patchwork/templates/patchwork/register.mail diff --git a/patchwork/notifications.py b/patchwork/notifications.py index 3ddd806b..45c081b9 100644 --- a/patchwork/notifications.py +++ b/patchwork/notifications.py @@ -76,10 +76,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 fab141d7..45283eba 100644 --- a/patchwork/views/mail.py +++ b/patchwork/views/mail.py @@ -82,7 +82,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 1204baeb..848f86e5 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -65,11 +65,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]) @@ -149,10 +151,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: From patchwork Mon Sep 17 14:17:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DStN133qz9sfR for ; Tue, 18 Sep 2018 00:19:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="IAV4q9Ha"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DStM6YvhzF31P for ; Tue, 18 Sep 2018 00:19:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="IAV4q9Ha"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.6; helo=relay-direct6.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="IAV4q9Ha"; dkim-atps=neutral Received: from relay-direct6.mxroute.com (relay-direct6.mxroute.com [185.234.75.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsN4hJYzF1fD for ; Tue, 18 Sep 2018 00:18:32 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct6.mxroute.com (Postfix) with ESMTP id 9B67A3F352 for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 79D853F3E0 for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tRRh0JqtMd1I4ffLfCI3iD58GAUMWl5OezdT0VjykUY=; b=IAV4q9HajiUE2ev2KDoqs8g/FK LyNSRKZDXFTQ1KGqbJnxKG0HmaJYIVIRP3VZAPnIXdeEP4qPUsYI+4cCFY3diKPtU1r0YGspaZYpF AG4FqrPrWws+qmvl+mgPaoQN5Kt2r717plyGFduAdKAPalQuCxWCpfOAs5fkR3vmBB+iYhgi69Gcg v+55pQYYxZFh0VSMtMev6IzxQRk0JQ4AtSgWxtH6sJMXsvOArJknZ6KD+eEnUBw1MhyMAN0T0vXk0 j6h5OEO1nCNE/YxuyzSh/ypUZjBwv+pMpVg8lGOQEuPVs3uyjLa/09jqUpsll9HuMmHuRmLDuB/tV 5a1SGABg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/6] templates: Rename additional templates Date: Mon, 17 Sep 2018 15:17:46 +0100 Message-Id: <20180917141750.21508-2-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917141750.21508-1-stephen@that.guru> References: <20180917141750.21508-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Make ALL the things consistent. Signed-off-by: Stephen Finucane --- .../{download_buttons.html => download-buttons.html} | 0 patchwork/templates/patchwork/{mail-form.html => mail.html} | 0 .../patchwork/{registration_form.html => registration.html} | 0 patchwork/templates/patchwork/submission.html | 4 ++-- patchwork/tests/test_mail_settings.py | 4 ++-- patchwork/tests/test_registration.py | 2 +- patchwork/views/mail.py | 2 +- patchwork/views/user.py | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename patchwork/templates/patchwork/{download_buttons.html => download-buttons.html} (100%) rename patchwork/templates/patchwork/{mail-form.html => mail.html} (100%) rename patchwork/templates/patchwork/{registration_form.html => registration.html} (100%) diff --git a/patchwork/templates/patchwork/download_buttons.html b/patchwork/templates/patchwork/download-buttons.html similarity index 100% rename from patchwork/templates/patchwork/download_buttons.html rename to patchwork/templates/patchwork/download-buttons.html diff --git a/patchwork/templates/patchwork/mail-form.html b/patchwork/templates/patchwork/mail.html similarity index 100% rename from patchwork/templates/patchwork/mail-form.html rename to patchwork/templates/patchwork/mail.html diff --git a/patchwork/templates/patchwork/registration_form.html b/patchwork/templates/patchwork/registration.html similarity index 100% rename from patchwork/templates/patchwork/registration_form.html rename to patchwork/templates/patchwork/registration.html diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index f03e1408..6e189b27 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -28,7 +28,7 @@ function toggle_div(link_id, headers_id)

{{ submission.name }} -{% include "patchwork/download_buttons.html" %} +{% include "patchwork/download-buttons.html" %}

@@ -285,7 +285,7 @@ function toggle_div(link_id, headers_id) {% if submission.diff %}

Patch - {% include "patchwork/download_buttons.html" %} + {% include "patchwork/download-buttons.html" %}

diff --git a/patchwork/tests/test_mail_settings.py b/patchwork/tests/test_mail_settings.py index 6d56f5a8..70e135d5 100644 --- a/patchwork/tests/test_mail_settings.py +++ b/patchwork/tests/test_mail_settings.py @@ -46,14 +46,14 @@ class MailSettingsTest(TestCase): def test_post_empty(self): response = self.client.post(reverse('mail-settings'), {'email': ''}) self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'patchwork/mail-form.html') + self.assertTemplateUsed(response, 'patchwork/mail.html') self.assertFormError(response, 'form', 'email', 'This field is required.') def test_post_invalid(self): response = self.client.post(reverse('mail-settings'), {'email': 'foo'}) self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'patchwork/mail-form.html') + self.assertTemplateUsed(response, 'patchwork/mail.html') self.assertFormError(response, 'form', 'email', error_strings['email']) def test_post_optin(self): diff --git a/patchwork/tests/test_registration.py b/patchwork/tests/test_registration.py index 616254d2..ad8ead23 100644 --- a/patchwork/tests/test_registration.py +++ b/patchwork/tests/test_registration.py @@ -55,7 +55,7 @@ class RegistrationTest(TestCase): def test_registration_form(self): response = self.client.get('/register/') self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'patchwork/registration_form.html') + self.assertTemplateUsed(response, 'patchwork/registration.html') def test_blank_fields(self): for field in ['username', 'email', 'password']: diff --git a/patchwork/views/mail.py b/patchwork/views/mail.py index 45283eba..12825a13 100644 --- a/patchwork/views/mail.py +++ b/patchwork/views/mail.py @@ -48,7 +48,7 @@ def settings(request): 'form': form, } - return render(request, 'patchwork/mail-form.html', context) + return render(request, 'patchwork/mail.html', context) def optout_confirm(request, conf): diff --git a/patchwork/views/user.py b/patchwork/views/user.py index 848f86e5..cb8e61af 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -82,7 +82,7 @@ def register(request): context['form'] = form - return render(request, 'patchwork/registration_form.html', context) + return render(request, 'patchwork/registration.html', context) def register_confirm(request, conf): From patchwork Mon Sep 17 14:17:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DSsV0bQnz9shy for ; Tue, 18 Sep 2018 00:18:38 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="i3HR3Rqz"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DSsT58VZzF2ZL for ; Tue, 18 Sep 2018 00:18:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="i3HR3Rqz"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.9; helo=relay002.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="i3HR3Rqz"; dkim-atps=neutral Received: from relay002.mxroute.com (unknown [185.234.75.9]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsN5gvhzF2QL for ; Tue, 18 Sep 2018 00:18:32 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay001.mxroute.com (Postfix) with ESMTP id ED19841C83 for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id D67B13F3E0 for ; Mon, 17 Sep 2018 14:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=riebuxl8Xx2RqYhE0jLzTrrIKOYcLQ4tNAEI6OiyXPs=; b=i3HR3Rqz2Q7JtN+oZMb3e3bYwe feYOkNkdgw18fmpF4/IWcIHETn/WBHrkleY4w02RLIZdmNv03PevzRldY+yGU0ab2gXYhp1uxPglr dAdMScBwgLmotbEgHojhCYT0jpC/7dFqHrnycgWrMhyua3gNZUdKfQed/fYTPWnMC2SOoLnO4pK3/ WomyUKA/bJ2/+ydPCAFEWv9mWuGHpJYMqCKKi15DHM9eCw8C8xiHII8sqigkik3r2XLSLUxDrwGe3 rXETgw464lfcUJnvU5zBITZ7T0LkOQCebe5Z9ZST70I/SfaY90U4NWDH8shwzYtrLwS6Jyi4wIvb/ B3/ZU+Wg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 3/6] templates: Keep only whole templates in the top-level Date: Mon, 17 Sep 2018 15:17:47 +0100 Message-Id: <20180917141750.21508-3-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917141750.21508-1-stephen@that.guru> References: <20180917141750.21508-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Again, this should make this a little more understandable as it ensures a rough mapping exists between views and template names. Signed-off-by: Stephen Finucane --- patchwork/templates/patchwork/bundle.html | 2 +- patchwork/templates/patchwork/list.html | 2 +- .../patchwork/{ => partials}/download-buttons.html | 0 patchwork/templates/patchwork/{ => partials}/filters.html | 0 .../templates/patchwork/{ => partials}/pagination.html | 0 .../templates/patchwork/{ => partials}/patch-list.html | 6 +++--- patchwork/templates/patchwork/submission.html | 4 ++-- patchwork/templates/patchwork/todo-list.html | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename patchwork/templates/patchwork/{ => partials}/download-buttons.html (100%) rename patchwork/templates/patchwork/{ => partials}/filters.html (100%) rename patchwork/templates/patchwork/{ => partials}/pagination.html (100%) rename patchwork/templates/patchwork/{ => partials}/patch-list.html (98%) diff --git a/patchwork/templates/patchwork/bundle.html b/patchwork/templates/patchwork/bundle.html index 2042cb96..b5c9f90a 100644 --- a/patchwork/templates/patchwork/bundle.html +++ b/patchwork/templates/patchwork/bundle.html @@ -40,6 +40,6 @@ project.

{% endif %} -{% include "patchwork/patch-list.html" %} +{% include "patchwork/partials/patch-list.html" %} {% endblock %} diff --git a/patchwork/templates/patchwork/list.html b/patchwork/templates/patchwork/list.html index 180c5607..5d3d82aa 100644 --- a/patchwork/templates/patchwork/list.html +++ b/patchwork/templates/patchwork/list.html @@ -18,6 +18,6 @@ while updating patches:

{% endif %} -{% include "patchwork/patch-list.html" %} +{% include "patchwork/partials/patch-list.html" %} {% endblock %} diff --git a/patchwork/templates/patchwork/download-buttons.html b/patchwork/templates/patchwork/partials/download-buttons.html similarity index 100% rename from patchwork/templates/patchwork/download-buttons.html rename to patchwork/templates/patchwork/partials/download-buttons.html diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/partials/filters.html similarity index 100% rename from patchwork/templates/patchwork/filters.html rename to patchwork/templates/patchwork/partials/filters.html diff --git a/patchwork/templates/patchwork/pagination.html b/patchwork/templates/patchwork/partials/pagination.html similarity index 100% rename from patchwork/templates/patchwork/pagination.html rename to patchwork/templates/patchwork/partials/pagination.html diff --git a/patchwork/templates/patchwork/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html similarity index 98% rename from patchwork/templates/patchwork/patch-list.html rename to patchwork/templates/patchwork/partials/patch-list.html index 71c1ba92..53d577de 100644 --- a/patchwork/templates/patchwork/patch-list.html +++ b/patchwork/templates/patchwork/partials/patch-list.html @@ -4,9 +4,9 @@ {% load project %} {% load static %} -{% include "patchwork/filters.html" %} +{% include "patchwork/partials/filters.html" %} -{% include "patchwork/pagination.html" %} +{% include "patchwork/partials/pagination.html" %} {% if order.editable %}
@@ -218,7 +218,7 @@ $(document).ready(function() {
{% if page.paginator.count %} -{% include "patchwork/pagination.html" %} +{% include "patchwork/partials/pagination.html" %}
diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 6e189b27..eb5e3583 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -28,7 +28,7 @@ function toggle_div(link_id, headers_id)

{{ submission.name }} -{% include "patchwork/download-buttons.html" %} +{% include "patchwork/partials/download-buttons.html" %}

@@ -285,7 +285,7 @@ function toggle_div(link_id, headers_id) {% if submission.diff %}

Patch - {% include "patchwork/download-buttons.html" %} + {% include "patchwork/partials/download-buttons.html" %}

diff --git a/patchwork/templates/patchwork/todo-list.html b/patchwork/templates/patchwork/todo-list.html index 444baa01..1ec2713d 100644 --- a/patchwork/templates/patchwork/todo-list.html +++ b/patchwork/templates/patchwork/todo-list.html @@ -12,6 +12,6 @@ are in an "action required" state ({% for state in action_required_states %}{% if forloop.last and not forloop.first %} or {% endif %}{{ state }}{% if not forloop.last and not forloop.first %}, {%endif %}{% endfor %}), and are not archived.

-{% include "patchwork/patch-list.html" %} +{% include "patchwork/partials/patch-list.html" %} {% endblock %} From patchwork Mon Sep 17 14:17:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DStp2byVz9sfR for ; Tue, 18 Sep 2018 00:19:46 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="jru8SNwm"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DStp0vw3zF31F for ; Tue, 18 Sep 2018 00:19:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="jru8SNwm"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.6; helo=relay-direct6.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="jru8SNwm"; dkim-atps=neutral Received: from relay-direct6.mxroute.com (relay-direct6.mxroute.com [185.234.75.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsP2bMszF2QM for ; Tue, 18 Sep 2018 00:18:32 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct6.mxroute.com (Postfix) with ESMTP id 99DDF3F357 for ; Mon, 17 Sep 2018 14:18:00 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 818C83F3E0 for ; Mon, 17 Sep 2018 14:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=W25Qn9nFYvVjrJ//jp/71+htu0BEnEa/yOQRrxnZNSI=; b=jru8SNwmHvBVtLoUdgxHK62ajg 6MJi5sCXRNAsePOv/HK5hdSJBzXDnj6LKh9NFPUufUoPMBD8jwU/5UnW6xtDZ66B4Ercibt7D5Pz6 c3+PY9JlqJ13d76d9shKv6sJB869k8a5ZaSIW4nU8+0F0If2QhlA6xzOkiStnLaKxxcnRNgGNZNAk 2z5K2ZrBax9mPSQi50qfFWv/w2w3S/VAxvagTDCjGhP/h/RD7bqkJgjiOHSzdUzJKYXAqvLN5T7pK guIpdVQtSF3njdlTXLaF5TxwPub6NkTiyXuTVQlvxJi2rzp23610VQLbOdgGD8r4oj7nM5w/51/rg U5jXCmYg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 4/6] templates: Move additional email subjects to templates Date: Mon, 17 Sep 2018 15:17:48 +0100 Message-Id: <20180917141750.21508-4-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917141750.21508-1-stephen@that.guru> References: <20180917141750.21508-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Use a uniform pattern for this stuff. Signed-off-by: Stephen Finucane --- .../patchwork/mails/optin-request-subject.txt | 1 + .../mails/optout-request-subject.txt | 1 + .../patchwork/mails/user-link-subject.txt | 1 + patchwork/views/mail.py | 19 +++++++++++-------- patchwork/views/user.py | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 patchwork/templates/patchwork/mails/optin-request-subject.txt create mode 100644 patchwork/templates/patchwork/mails/optout-request-subject.txt create mode 100644 patchwork/templates/patchwork/mails/user-link-subject.txt diff --git a/patchwork/templates/patchwork/mails/optin-request-subject.txt b/patchwork/templates/patchwork/mails/optin-request-subject.txt new file mode 100644 index 00000000..9733b6f3 --- /dev/null +++ b/patchwork/templates/patchwork/mails/optin-request-subject.txt @@ -0,0 +1 @@ +Patchwork opt-in request \ No newline at end of file diff --git a/patchwork/templates/patchwork/mails/optout-request-subject.txt b/patchwork/templates/patchwork/mails/optout-request-subject.txt new file mode 100644 index 00000000..377dfc89 --- /dev/null +++ b/patchwork/templates/patchwork/mails/optout-request-subject.txt @@ -0,0 +1 @@ +Patchwork opt-out confirmation \ No newline at end of file diff --git a/patchwork/templates/patchwork/mails/user-link-subject.txt b/patchwork/templates/patchwork/mails/user-link-subject.txt new file mode 100644 index 00000000..8ac4d1d4 --- /dev/null +++ b/patchwork/templates/patchwork/mails/user-link-subject.txt @@ -0,0 +1 @@ +Patchwork email address confirmation \ No newline at end of file diff --git a/patchwork/views/mail.py b/patchwork/views/mail.py index 12825a13..1ce37736 100644 --- a/patchwork/views/mail.py +++ b/patchwork/views/mail.py @@ -80,9 +80,10 @@ def optin_confirm(request, conf): return render(request, 'patchwork/optin.html', context) -def _optinout(request, action, description): +def _optinout(request, action): context = {} mail_template = 'patchwork/mails/%s-request.txt' % action + mail_subject_template = 'patchwork/mails/%s-request-subject.txt' % action html_template = 'patchwork/%s-request.html' % action if request.method != 'POST': @@ -90,8 +91,8 @@ def _optinout(request, action, description): form = EmailForm(data=request.POST) if not form.is_valid(): - context['error'] = ('There was an error in the %s form. Please ' - 'review the form and re-submit.' % description) + context['error'] = ('There was an error in the form. Please review ' + 'and re-submit.') context['form'] = form return render(request, html_template, context) @@ -108,11 +109,13 @@ def _optinout(request, action, description): conf.save() context['confirmation'] = conf - mail = render_to_string(mail_template, context, request=request) + + subject = render_to_string(mail_subject_template) + message = render_to_string(mail_template, context, request=request) try: - send_mail('Patchwork %s confirmation' % description, mail, - conf_settings.DEFAULT_FROM_EMAIL, [email]) + send_mail(subject, message, conf_settings.DEFAULT_FROM_EMAIL, [email]) + # TODO(stephenfin): This is unnecessary and can be removed context['email_sent'] = True except smtplib.SMTPException: context['error'] = ('An error occurred during confirmation . ' @@ -123,8 +126,8 @@ def _optinout(request, action, description): def optout(request): - return _optinout(request, 'optout', 'opt-out') + return _optinout(request, 'optout') def optin(request): - return _optinout(request, 'optin', 'opt-in') + return _optinout(request, 'optin') diff --git a/patchwork/views/user.py b/patchwork/views/user.py index cb8e61af..6348bed6 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -151,7 +151,7 @@ def link(request): context['confirmation'] = conf - subject = 'Patchwork email address confirmation', + subject = render_to_string('patchwork/mails/user-link-subject.txt') message = render_to_string('patchwork/mails/user-link.txt', context, request=request) try: From patchwork Mon Sep 17 14:17:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DSvF6FsWz9shy for ; Tue, 18 Sep 2018 00:20:09 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="tWunc6K+"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DSvF4M13zF2Nm for ; Tue, 18 Sep 2018 00:20:09 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="tWunc6K+"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.9; helo=relay002.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="tWunc6K+"; dkim-atps=neutral Received: from relay002.mxroute.com (unknown [185.234.75.9]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsP5t1xzF1fD for ; Tue, 18 Sep 2018 00:18:33 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay001.mxroute.com (Postfix) with ESMTP id 653EE41C96 for ; Mon, 17 Sep 2018 14:18:01 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 4F8D93F3E0 for ; Mon, 17 Sep 2018 14:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=KA0oYXA6rPEJo6Sk6qaxlnb2i1DOhG7zEdQ1PIkiQPw=; b=tWunc6K+NilyapRs3PwaXB5yfo i9bV5aT4/v7eFRbcaEReE1SA4BMAFj+HBQ4RaJKb1/49roM8cJlNvJ51j4zm9zE/etgFFe3CP8vS8 9YB6FURvNENAjJwANo6tCrZM5hmS91Ep0r1UP8YfwswAZk251NY7Dq2RR3NQcsFU1AuIKdGzaIt0Q 3WCzcIrEx0jk1O9wItaqnKphnJVTjfsdnIZ/OxyxiHCSaudEVW4OsS8ex5CNKMzV5RJI0UbNDugpZ KSHqEeJSEj8tzfWt/eDeJ3Sc69JDwcKQM/pbTfVDUAoiE+PpZ/jlrXVzLsBNkjgRrtTo3ng/rCJE0 kkVIiOOQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 5/6] templates: Remove 'email_sent' attribute Date: Mon, 17 Sep 2018 15:17:49 +0100 Message-Id: <20180917141750.21508-5-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917141750.21508-1-stephen@that.guru> References: <20180917141750.21508-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Further normalization to ensure all related code paths use similar code. Signed-off-by: Stephen Finucane --- patchwork/templates/patchwork/optin-request.html | 2 +- patchwork/templates/patchwork/optout-request.html | 2 +- patchwork/tests/test_mail_settings.py | 8 ++++---- patchwork/views/mail.py | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/patchwork/templates/patchwork/optin-request.html b/patchwork/templates/patchwork/optin-request.html index dfc104e8..90963e65 100644 --- a/patchwork/templates/patchwork/optin-request.html +++ b/patchwork/templates/patchwork/optin-request.html @@ -4,7 +4,7 @@ {% block heading %}Opt-in{% endblock %} {% block body %} -{% if email_sent %} +{% if confirmation %}

Opt-in confirmation email sent

An opt-in confirmation mail has been sent to {{confirmation.email}}, containing a link. Please click on diff --git a/patchwork/templates/patchwork/optout-request.html b/patchwork/templates/patchwork/optout-request.html index eae05e62..659af773 100644 --- a/patchwork/templates/patchwork/optout-request.html +++ b/patchwork/templates/patchwork/optout-request.html @@ -4,7 +4,7 @@ {% block heading %}Opt-out{% endblock %} {% block body %} -{% if email_sent %} +{% if confirmation %}

Opt-out confirmation email sent

An opt-out confirmation mail has been sent to {{confirmation.email}}, containing a link. Please click on diff --git a/patchwork/tests/test_mail_settings.py b/patchwork/tests/test_mail_settings.py index 70e135d5..8844212e 100644 --- a/patchwork/tests/test_mail_settings.py +++ b/patchwork/tests/test_mail_settings.py @@ -108,7 +108,7 @@ class OptoutRequestTest(TestCase): self.assertFormError(response, 'form', 'email', 'This field is required.') self.assertTrue(response.context['error']) - self.assertNotIn('email_sent', response.context) + self.assertNotIn('confirmation', response.context) self.assertEqual(len(mail.outbox), 0) def test_post_non_email(self): @@ -116,7 +116,7 @@ class OptoutRequestTest(TestCase): self.assertEqual(response.status_code, 200) self.assertFormError(response, 'form', 'email', error_strings['email']) self.assertTrue(response.context['error']) - self.assertNotIn('email_sent', response.context) + self.assertNotIn('confirmation', response.context) self.assertEqual(len(mail.outbox), 0) @@ -189,7 +189,7 @@ class OptinRequestTest(TestCase): self.assertFormError(response, 'form', 'email', 'This field is required.') self.assertTrue(response.context['error']) - self.assertNotIn('email_sent', response.context) + self.assertNotIn('confirmation', response.context) self.assertEqual(len(mail.outbox), 0) def test_post_non_email(self): @@ -197,7 +197,7 @@ class OptinRequestTest(TestCase): self.assertEqual(response.status_code, 200) self.assertFormError(response, 'form', 'email', error_strings['email']) self.assertTrue(response.context['error']) - self.assertNotIn('email_sent', response.context) + self.assertNotIn('confirmation', response.context) self.assertEqual(len(mail.outbox), 0) diff --git a/patchwork/views/mail.py b/patchwork/views/mail.py index 1ce37736..6a3c1c25 100644 --- a/patchwork/views/mail.py +++ b/patchwork/views/mail.py @@ -97,8 +97,8 @@ def _optinout(request, action): return render(request, html_template, context) email = form.cleaned_data['email'] - if action == 'optin' and \ - EmailOptout.objects.filter(email=email).count() == 0: + if action == 'optin' and EmailOptout.objects.filter( + email=email).count() == 0: context['error'] = ("The email address %s is not on the patchwork " "opt-out list, so you don't need to opt back in" % email) @@ -115,9 +115,8 @@ def _optinout(request, action): try: send_mail(subject, message, conf_settings.DEFAULT_FROM_EMAIL, [email]) - # TODO(stephenfin): This is unnecessary and can be removed - context['email_sent'] = True except smtplib.SMTPException: + context['confirmation'] = None context['error'] = ('An error occurred during confirmation . ' 'Please try again later.') context['admins'] = conf_settings.ADMINS From patchwork Mon Sep 17 14:17:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 970611 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DSvl1VwBz9sfR for ; Tue, 18 Sep 2018 00:20:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="UyoO+VVm"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42DSvl037pzF2vT for ; Tue, 18 Sep 2018 00:20:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="UyoO+VVm"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.8; helo=relay001.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="UyoO+VVm"; dkim-atps=neutral Received: from relay001.mxroute.com (unknown [185.234.75.8]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42DSsQ2RmXzF2Nm for ; Tue, 18 Sep 2018 00:18:34 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay001.mxroute.com (Postfix) with ESMTP id D645841C9B for ; Mon, 17 Sep 2018 14:18:01 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id BD8CF3F3E0 for ; Mon, 17 Sep 2018 14:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gypXH5SQOFyliFJHB1e3jSe0vo+B/nK5JFu4Ko4/PYk=; b=UyoO+VVm7u8xeG8fludymiK6H0 WFk0cyNpt9dIPdBVnpJNJ6z23TYdPpwRAE6QX9hur5aXi7cEKLlGhc73LwBlA1uzCX6oKa9+Os6ei 45DSPHvWt/3BiGhhfv/e53uIguj0b2uXNfln+G/oTPlncAK6Vm4qQLN1UilZe8Z+XRY2M1qd+CHxJ PBpwQ3MJ3JKFzlP8UJyGz+lAy7MjoNKJfmJk92f5f8xsBncw4OqgyjoRUpEHBV3ADXI+SDIwQCqDy Q/q7lV4Ztf+KJ4fHWmcPqk/quTxGdE50xVPKcXUeThj7kp1WQUGbWMKr6uYqlsSFDmXltTElRPFZX fQmeE0sg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 6/6] views: Add error handling for user registration Date: Mon, 17 Sep 2018 15:17:50 +0100 Message-Id: <20180917141750.21508-6-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180917141750.21508-1-stephen@that.guru> References: <20180917141750.21508-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This was already present for registration confirmation but missing for initial registration. Resolve this. Signed-off-by: Stephen Finucane --- patchwork/views/user.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/patchwork/views/user.py b/patchwork/views/user.py index 6348bed6..9876da96 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -64,6 +64,8 @@ def register(request): email=user.email) conf.save() + context['confirmation'] = conf + # send email subject = render_to_string( 'patchwork/mails/activation-subject.txt') @@ -71,12 +73,13 @@ def register(request): '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]) - - # setting 'confirmation' in the template indicates success - context['confirmation'] = conf + try: + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, + [conf.email]) + except smtplib.SMTPException: + context['confirmation'] = None + context['error'] = ('An error occurred during registration. ' + 'Please try again later') else: form = RegistrationForm()