mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 15:21:01 +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}/"
|
admin_view = "{admin}{self.pk}/"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_random(cls, email=None):
|
def create_random(cls, email=None, note=None):
|
||||||
return cls.objects.create(
|
return cls.objects.create(
|
||||||
token="".join(
|
token="".join(
|
||||||
random.choice("abcdefghkmnpqrstuvwxyz23456789") for i in range(20)
|
random.choice("abcdefghkmnpqrstuvwxyz23456789") for i in range(20)
|
||||||
),
|
),
|
||||||
email=email,
|
email=email,
|
||||||
|
note=note,
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,8 +43,11 @@ class InviteCreate(FormView):
|
||||||
)
|
)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
invite = Invite.create_random(email=form.cleaned_data.get("email") or None)
|
invite = Invite.create_random(
|
||||||
return redirect(invite.urls.admin)
|
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")
|
@method_decorator(moderator_required, name="dispatch")
|
||||||
|
|
Loading…
Reference in a new issue