|
@@ -3,6 +3,7 @@ from PIL import Image
|
|
from django.shortcuts import redirect, render
|
|
from django.shortcuts import redirect, render
|
|
from django.template import loader
|
|
from django.template import loader
|
|
|
|
|
|
|
|
+from django.core import mail
|
|
from django.http import HttpResponse, FileResponse
|
|
from django.http import HttpResponse, FileResponse
|
|
from django.urls import reverse_lazy
|
|
from django.urls import reverse_lazy
|
|
from django.views.generic import UpdateView
|
|
from django.views.generic import UpdateView
|
|
@@ -42,8 +43,8 @@ def register(request):
|
|
if request.method == 'POST':
|
|
if request.method == 'POST':
|
|
form = SignUpForm(request.POST)
|
|
form = SignUpForm(request.POST)
|
|
if form.is_valid():
|
|
if form.is_valid():
|
|
- user = form.save()
|
|
|
|
- user.refresh_from_db()
|
|
|
|
|
|
+ user: User = form.save()
|
|
|
|
+ user.refresh_from_db()
|
|
# load the profile instance created by the signal
|
|
# load the profile instance created by the signal
|
|
user.save()
|
|
user.save()
|
|
raw_password = form.cleaned_data.get('password1')
|
|
raw_password = form.cleaned_data.get('password1')
|
|
@@ -52,6 +53,17 @@ def register(request):
|
|
user = auth.authenticate(username=user.username, password=raw_password)
|
|
user = auth.authenticate(username=user.username, password=raw_password)
|
|
auth.login(request, user)
|
|
auth.login(request, user)
|
|
|
|
|
|
|
|
+ # notify admin
|
|
|
|
+ with mail.get_connection() as connection:
|
|
|
|
+ mail.mail_admins(
|
|
|
|
+ f"{user.get_full_name()} has registered to 'Stammbaum'",
|
|
|
|
+ f"{user.username} ({user.get_full_name()}) <{user.email}> has registered to 'Stammbaum'.\n" +
|
|
|
|
+ f"Please update their permissions accordingly.\n" +
|
|
|
|
+ f"https://pi.justprojects.de/admin/auth/user/{user.id}/change/",
|
|
|
|
+ False,
|
|
|
|
+ connection
|
|
|
|
+ )
|
|
|
|
+
|
|
# redirect user to home page
|
|
# redirect user to home page
|
|
return redirect('/stammbaum/')
|
|
return redirect('/stammbaum/')
|
|
else:
|
|
else:
|