Source

django-confirmation / confirmation / views.py

Full commit
from django.shortcuts import redirect

from annoying.decorators import render_to

from confirmation.models import Confirmation
from confirmation import signals


@render_to("confirmation/confirmation.html")
def confirmation(request):
    """
    Check confirmation key and type. If match - emit succeffull_confirmation signal, 
    then delete confirmation.
    """
    key = request.GET.get("key")
    confirmation_type = int(request.GET.get("type", 1))
    
    confirmation = Confirmation.objects.get(key=key, confirmation_type=confirmation_type)
    
    if confirmation:
        signals.successfull_confirmation.send(Confirmation, 
                                              request=request,
                                              instance=confirmation.content_object, 
                                              confirmation_type=confirmation.confirmation_type)
        
    if confirmation.redirect_url:
        return redirect(confirmation.redirect_url)
    return {}