|
|
@ -1,10 +1,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
from django.contrib.auth.tokens import PasswordResetTokenGenerator |
|
|
|
from django.contrib.sites.shortcuts import get_current_site |
|
|
|
from django.shortcuts import get_object_or_404, render, redirect |
|
|
|
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, JsonResponse |
|
|
|
from django.urls import reverse,reverse_lazy |
|
|
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist |
|
|
|
from django.core.mail import send_mail |
|
|
|
from django.utils.encoding import force_bytes |
|
|
|
from django.utils.http import urlsafe_base64_encode |
|
|
|
from django.views import generic |
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
|
@ -1189,7 +1191,6 @@ def prihlaskaView(request): |
|
|
|
with transaction.atomic(): |
|
|
|
u = User.objects.create_user( |
|
|
|
username=fcd['username'], |
|
|
|
password=fcd['password'], |
|
|
|
email = fcd['email']) |
|
|
|
u.save() |
|
|
|
resitel_perm = Permission.objects.filter(codename__exact='resitel').first() |
|
|
@ -1240,11 +1241,19 @@ def prihlaskaView(request): |
|
|
|
err_logger.warn(msg + str(form_hash)) |
|
|
|
r.save() |
|
|
|
|
|
|
|
send_mail( |
|
|
|
uid = urlsafe_base64_encode(force_bytes(u.pk)) |
|
|
|
token = PasswordResetTokenGenerator().make_token(u) |
|
|
|
url = "https://%s%s" % ( |
|
|
|
str(get_current_site(request)), |
|
|
|
str(reverse_lazy("password_reset_confirm", args=[uid, token])) |
|
|
|
) |
|
|
|
|
|
|
|
u.email_user( |
|
|
|
subject="Registrace na M&M", |
|
|
|
message=f"Tento e-mail byl právě zaregistrován na mam.matfyz.cz.", # TODO: Dovymyslet text. |
|
|
|
message=f"Tento e-mail byl právě zaregistrován na mam.matfyz.cz. Nové heslo si nastavíš na: " + url, |
|
|
|
# TODO: templates/seminar/registrace a django/contrib/auth/forms.py říkají, jak na to lépe |
|
|
|
# TODO: Dovymyslet text. |
|
|
|
from_email="registrace@mam.mff.cuni.cz", # FIXME: Chceme to mít radši tady, nebo v nastavení? |
|
|
|
recipient_list=list([fcd['email']]), |
|
|
|
) |
|
|
|
|
|
|
|
return formularOKView(request) |
|
|
|