From caf775b31b2c31b37859d66d5d04b8eb8f9a4b73 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Wed, 28 Nov 2018 08:19:31 +0100 Subject: [PATCH] Make the e-mail stream field validate e-mail addresses. --- opentech/apply/funds/blocks.py | 1 + opentech/apply/funds/tests/test_models.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py index ad00ba86f..d6a87a5f9 100644 --- a/opentech/apply/funds/blocks.py +++ b/opentech/apply/funds/blocks.py @@ -44,6 +44,7 @@ class EmailBlock(ApplicationMustIncludeFieldBlock): name = 'email' description = 'The applicant email address' widget = forms.EmailInput + field_class = forms.EmailField class Meta: icon = 'mail' diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py index 5943d8b76..b606227e4 100644 --- a/opentech/apply/funds/tests/test_models.py +++ b/opentech/apply/funds/tests/test_models.py @@ -306,6 +306,11 @@ class TestFormSubmission(TestCase): self.assertEqual(ApplicationSubmission.objects.count(), 0) + def test_valid_email(self): + email = 'not_a_valid_email@' + response = self.submit_form(email=email, ignore_errors=True) + self.assertContains(response, 'Enter a valid email address') + @override_settings(SEND_MESSAGES=True) def test_email_sent_to_user_on_submission_fund(self): self.submit_form() -- GitLab