def optout_confirm(request, conf): email = conf.email.strip().lower() # silently ignore duplicated optouts if EmailOptout.objects.filter(email=email).count() == 0: optout = EmailOptout(email=email) optout.save() conf.deactivate() return render(request, 'patchwork/optout.html', {'email': conf.email})
def optout_confirm(request, conf): context = PatchworkRequestContext(request) email = conf.email.strip().lower() # silently ignore duplicated optouts if EmailOptout.objects.filter(email = email).count() == 0: optout = EmailOptout(email = email) optout.save() conf.deactivate() context['email'] = conf.email return render_to_response('patchwork/optout.html', context)
def optout_confirm(request, conf): context = PatchworkRequestContext(request) email = conf.email.strip().lower() # silently ignore duplicated optouts if EmailOptout.objects.filter(email=email).count() == 0: optout = EmailOptout(email=email) optout.save() conf.deactivate() context['email'] = conf.email return render_to_response('patchwork/optout.html', context)
def optout_confirm(request, conf): email = conf.email.strip().lower() # silently ignore duplicated optouts if EmailOptout.objects.filter(email=email).count() == 0: optout = EmailOptout(email=email) optout.save() conf.deactivate() context = { 'email': conf.email, } return render(request, 'patchwork/optout.html', context)
class OptinTest(TestCase): def setUp(self): self.email = u'*****@*****.**' self.optout = EmailOptout(email=self.email) self.optout.save() self.conf = EmailConfirmation(type='optin', email=self.email) self.conf.save() def testOptinValidHash(self): url = reverse('confirm', kwargs={'key': self.conf.key}) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'patchwork/optin.html') self.assertContains(response, self.email) # check that there's no optout remaining self.assertEqual(EmailOptout.objects.count(), 0) # check that the confirmation is now inactive self.assertFalse(EmailConfirmation.objects.get(pk=self.conf.pk).active)
class OptinTest(TestCase): def setUp(self): self.email = u'*****@*****.**' self.optout = EmailOptout(email=self.email) self.optout.save() self.conf = EmailConfirmation(type='optin', email=self.email) self.conf.save() def test_valid_hash(self): response = self.client.get( reverse('confirm', kwargs={'key': self.conf.key})) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'patchwork/optin.html') self.assertContains(response, self.email) # check that there's no optout remaining self.assertEqual(EmailOptout.objects.count(), 0) # check that the confirmation is now inactive self.assertFalse(EmailConfirmation.objects.get( pk=self.conf.pk).active)