From 98d0851f5864225fc4ba3d7ab3657620c9876eec Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 31 Mar 2015 01:41:03 +0100 Subject: [PATCH 1/2] Added first & last name fields to registration form --- RIGS/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RIGS/forms.py b/RIGS/forms.py index b339003e..3d393bb2 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -10,6 +10,8 @@ from RIGS import models #Registration class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): + first_name = forms.CharField(required=False, max_length=50) + last_name = forms.CharField(required=False, max_length=50) initials = forms.CharField(required=True, max_length=5) phone = forms.CharField(required=False, max_length=13) From a2be5d00b8fecf7224e16878310e9cc635c03310 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 31 Mar 2015 02:05:50 +0100 Subject: [PATCH 2/2] Add unique initial validation --- RIGS/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RIGS/forms.py b/RIGS/forms.py index b339003e..edb4e301 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -13,6 +13,14 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): initials = forms.CharField(required=True, max_length=5) phone = forms.CharField(required=False, max_length=13) + def clean_initials(self): + """ + Validate that the supplied initials are unique. + """ + if models.Profile.objects.filter(initials__iexact=self.cleaned_data['initials']): + raise forms.ValidationError("These initials are already in use. Please supply different initials.") + return self.cleaned_data['initials'] + # Events Shit class EventForm(forms.ModelForm): datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS