Send notification on new user creations

This commit is contained in:
2022-12-18 17:49:42 +00:00
parent 8de99c1bcd
commit 50820172b1
2 changed files with 15 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ from django.views import View
from django.views.generic.edit import CreateView
from core.forms import NewUserForm
from core.lib.notify import raw_sendmsg
from core.lib.products import assemble_plan_map
from core.models import Plan, Session
@@ -91,6 +92,16 @@ class Signup(CreateView):
success_url = reverse_lazy("two_factor:login")
template_name = "registration/signup.html"
def form_valid(self, form):
"""If the form is valid, save the associated model."""
self.object = form.save()
raw_sendmsg(
f"New user signup: {self.object.username} - {self.object.email}",
title="New user",
topic=settings.NOTIFY_TOPIC,
)
return super().form_valid(form)
def get(self, request, *args, **kwargs):
if not settings.REGISTRATION_OPEN:
return render(request, "registration/registration_closed.html")