コード例 #1
0
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})
コード例 #2
0
ファイル: mail.py プロジェクト: asl/llvm-patchwork
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)
コード例 #3
0
ファイル: mail.py プロジェクト: ykhuat/patchwork
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)
コード例 #4
0
ファイル: mail.py プロジェクト: alialnu/patchwork
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)
コード例 #5
0
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)
コード例 #6
0
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)