forked from expo/troggle
allow new registration only once
This commit is contained in:
@@ -181,6 +181,9 @@ def write_users(registered_users, encryptedfile, git_string):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
class newregister_form(forms.Form): # not a model-form, just a form-form
|
class newregister_form(forms.Form): # not a model-form, just a form-form
|
||||||
|
"""This is the form for a new user who has not been on expo before and
|
||||||
|
does notalready have a username
|
||||||
|
"""
|
||||||
fullname = forms.CharField(strip=True, required=True,
|
fullname = forms.CharField(strip=True, required=True,
|
||||||
label="Forename Surname",
|
label="Forename Surname",
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
@@ -196,14 +199,22 @@ class newregister_form(forms.Form): # not a model-form, just a form-form
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super().clean()
|
cleaned_data = super().clean()
|
||||||
un = cleaned_data.get("fullname")
|
fullname = cleaned_data.get("fullname")
|
||||||
|
|
||||||
email = cleaned_data.get("email")
|
email = cleaned_data.get("email")
|
||||||
|
|
||||||
users = User.objects.filter(email=email)
|
users = User.objects.filter(email=email)
|
||||||
if len(users) != 0:
|
if len(users) != 0:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"Duplicate email address. Another registered user is already using this email address. Email addresses must be unique as that is how we reset forgotten passwords."
|
"Duplicate email address. Another registered user is already using this email address. Email addresses must be unique as that is how we reset forgotten passwords."
|
||||||
)
|
)
|
||||||
|
userslug = troggle_slugify(fullname)
|
||||||
|
people = Person.objects.filter(slug=userslug)
|
||||||
|
if len(people) != 0:
|
||||||
|
raise ValidationError(
|
||||||
|
"Duplicate name. There is already a username correspondng to this Forename Surname. " +
|
||||||
|
"If you have been on expo before, you need to use the other form at expo.survex.com/accounts/register/ ." +
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class register_form(forms.Form): # not a model-form, just a form-form
|
class register_form(forms.Form): # not a model-form, just a form-form
|
||||||
username = forms.CharField(strip=True, required=True,
|
username = forms.CharField(strip=True, required=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user