From d1e398a7b7861419985e4a3e4261a586d4dd5748 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Tue, 20 Dec 2022 14:38:42 +0000 Subject: [PATCH] Invite creation improvements --- users/models/invite.py | 3 ++- users/views/admin/invites.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/users/models/invite.py b/users/models/invite.py index b84b7af..e5c11c3 100644 --- a/users/models/invite.py +++ b/users/models/invite.py @@ -27,10 +27,11 @@ class Invite(models.Model): admin_view = "{admin}{self.pk}/" @classmethod - def create_random(cls, email=None): + def create_random(cls, email=None, note=None): return cls.objects.create( token="".join( random.choice("abcdefghkmnpqrstuvwxyz23456789") for i in range(20) ), email=email, + note=note, ) diff --git a/users/views/admin/invites.py b/users/views/admin/invites.py index 338763a..ef76adb 100644 --- a/users/views/admin/invites.py +++ b/users/views/admin/invites.py @@ -43,8 +43,11 @@ class InviteCreate(FormView): ) def form_valid(self, form): - invite = Invite.create_random(email=form.cleaned_data.get("email") or None) - return redirect(invite.urls.admin) + invite = Invite.create_random( + email=form.cleaned_data.get("email") or None, + note=form.cleaned_data.get("notes"), + ) + return redirect(invite.urls.admin_view) @method_decorator(moderator_required, name="dispatch")