2012-09-28 22:29:48 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright: (c) 2008, Jarek Zgoda <jarek.zgoda@gmail.com>
|
|
|
|
|
|
|
|
__revision__ = '$Id: views.py 21 2008-12-05 09:21:03Z jarek.zgoda $'
|
|
|
|
|
|
|
|
|
2017-03-16 14:08:27 +01:00
|
|
|
from django.shortcuts import render
|
2012-09-28 22:29:48 +02:00
|
|
|
from django.template import RequestContext
|
|
|
|
from django.conf import settings
|
2016-06-03 03:47:17 +02:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2012-09-28 22:29:48 +02:00
|
|
|
|
2017-07-22 00:27:45 +02:00
|
|
|
from confirmation.models import Confirmation, get_object_from_key, ConfirmationKeyException, \
|
|
|
|
render_confirmation_key_error
|
2016-09-12 07:51:02 +02:00
|
|
|
from zerver.models import PreregistrationUser
|
2013-06-17 18:01:22 +02:00
|
|
|
|
2017-07-07 11:14:12 +02:00
|
|
|
from typing import Any, Dict
|
2012-09-28 22:29:48 +02:00
|
|
|
|
2017-07-07 10:40:25 +02:00
|
|
|
# This is currently only used for confirming PreregistrationUser.
|
|
|
|
# Do not add other confirmation paths here.
|
2012-09-28 22:29:48 +02:00
|
|
|
def confirm(request, confirmation_key):
|
2016-06-03 03:47:17 +02:00
|
|
|
# type: (HttpRequest, str) -> HttpResponse
|
2017-07-22 00:27:45 +02:00
|
|
|
try:
|
2017-11-01 21:07:39 +01:00
|
|
|
get_object_from_key(confirmation_key, Confirmation.USER_REGISTRATION)
|
|
|
|
except ConfirmationKeyException:
|
|
|
|
try:
|
|
|
|
get_object_from_key(confirmation_key, Confirmation.INVITATION)
|
|
|
|
except ConfirmationKeyException as exception:
|
|
|
|
return render_confirmation_key_error(request, exception)
|
2017-07-22 00:27:45 +02:00
|
|
|
|
|
|
|
return render(request, 'confirmation/confirm_preregistrationuser.html',
|
|
|
|
context={
|
|
|
|
'key': confirmation_key,
|
|
|
|
'full_name': request.GET.get("full_name", None)})
|