Request invite flow

This commit is contained in:
Mouse Reeve
2021-03-20 19:14:41 -07:00
parent 4d07cb1eb5
commit d15396eb26
8 changed files with 81 additions and 16 deletions

View File

@ -3,6 +3,7 @@ import datetime
from collections import defaultdict
from django import forms
from django.core.exceptions import ValidationError
from django.forms import ModelForm, PasswordInput, widgets
from django.forms.widgets import Textarea
from django.utils import timezone
@ -203,6 +204,13 @@ class ExpiryWidget(widgets.Select):
class InviteRequestForm(CustomForm):
def clean(self):
""" make sure the email isn't in use by a registered user """
cleaned_data = super().clean()
email = cleaned_data.get("email")
if email and models.User.objects.filter(email=email).exists():
self.add_error("email", _("A user with this email already exists."))
class Meta:
model = models.InviteRequest
fields = ["email"]