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):
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)
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):
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)
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)
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