From 4b2b684241fd6625ab732ca35d43cf3c2dd57c9f Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sat, 8 Dec 2018 19:33:40 +0100 Subject: [PATCH] Force le lowercase pour les pseudo des nouveaux utilisateurs --- users/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/users/forms.py b/users/forms.py index 8b496019..b5d7bc6d 100644 --- a/users/forms.py +++ b/users/forms.py @@ -323,6 +323,14 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): self.fields['room'].empty_label = _("No room") self.fields['school'].empty_label = _("Select a school") + def clean_pseudo(self): + """VĂ©rfie que le peusdo est bien en minuscule""" + pseudo = self.cleaned_data.get('pseudo') + if pseudo.islower(): + return pseudo + else: + raise forms.ValidationError(_("Your pseudo should be in lowercase.")) + def clean_email(self): if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get('email'): return self.cleaned_data.get('email').lower()