mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-14 03:11:46 +00:00
Invite creation improvements
This commit is contained in:
parent
2fefd02e77
commit
d1e398a7b7
2 changed files with 7 additions and 3 deletions
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue