Source

django-petition / petition / views.py

from django.views.generic.edit import CreateView
from petition.forms import PetitionForm
from django.views.generic.list import ListView
from petition.models import Signature
from django.shortcuts import get_object_or_404, redirect

class SignPetition(CreateView):
    form_class = PetitionForm
    template_name = 'petition/sign_petition.html'

class Signatures(ListView):
    queryset = Signature.objects.filter(confirmed=True)
    template_name = 'petition/signatures.html'

def verify_email(req, signature_id, email_hash):
    signature = get_object_or_404(Signature, pk=signature_id, confirmed=False)
    if email_hash == signature.get_email_hash():
        signature.confirmed = True
        signature.save()
        return redirect('email-confirmed')
    return redirect('email-failure')