summaryrefslogtreecommitdiffstats
path: root/core/views/user_registration.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-01-24 22:48:45 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2025-01-24 22:48:45 +0000
commit9c3a40dd98cb5d913bc2e2eb3c7cbf2f9be3e05f (patch)
treef15b7ecbbe6807429aa6b84bc4c68971c1b48ea1 /core/views/user_registration.py
parent8af4fc5b902b366ef1801e987aea8cae7ae83596 (diff)
downloadtroggle-9c3a40dd98cb5d913bc2e2eb3c7cbf2f9be3e05f.tar.gz
troggle-9c3a40dd98cb5d913bc2e2eb3c7cbf2f9be3e05f.tar.bz2
troggle-9c3a40dd98cb5d913bc2e2eb3c7cbf2f9be3e05f.zip
allow new registration only once
Diffstat (limited to 'core/views/user_registration.py')
-rw-r--r--core/views/user_registration.py15
1 files changed, 13 insertions, 2 deletions
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,