from django.urls import reverse_lazy from django.views.generic import CreateView from backend.accounts.forms import SignupForm from .models import EmailConfirmation from django.shortcuts import get_object_or_404, render from django.http import HttpResponse from backend.accounts.utils import send_confirmation_email class SignUpView(CreateView): form_class = SignupForm success_url = reverse_lazy('login') template_name = 'accounts/signup.html' def confirm_email(request,uuid): confirmation = get_object_or_404(EmailConfirmation, uuid=uuid) if confirmation.is_expired(): return render(request,'confirmation_expired.html', {'email': confirmation.email}) return HttpResponse("Email is confirmed") def resend_confirmation(request,email): if request.method == 'POST': send_confirmation_email(email) return HttpResponse("Confirmation email resent")