From 9c3a40dd98cb5d913bc2e2eb3c7cbf2f9be3e05f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 24 Jan 2025 22:48:45 +0000 Subject: allow new registration only once --- core/views/user_registration.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'core/views/user_registration.py') diff --git a/core/views/user_registration.py b/core/views/user_registration.py index 218b593..c0b3235 100644 --- a/core/views/user_registration.py +++ b/core/views/user_registration.py @@ -181,6 +181,9 @@ def write_users(registered_users, encryptedfile, git_string): return True 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, label="Forename Surname", widget=forms.TextInput( @@ -196,14 +199,22 @@ class newregister_form(forms.Form): # not a model-form, just a form-form def clean(self): cleaned_data = super().clean() - un = cleaned_data.get("fullname") - + fullname = cleaned_data.get("fullname") email = cleaned_data.get("email") + users = User.objects.filter(email=email) if len(users) != 0: 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." ) + 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 username = forms.CharField(strip=True, required=True, -- cgit v1.2.3