8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

verification des extension mail externe et lower des adresses mail pour mieux verifier les doublons

This commit is contained in:
grisel-davy 2018-08-09 23:43:35 +02:00 committed by Gabriel Detraz
parent 62d86be364
commit 351495e7ff

View file

@ -620,6 +620,9 @@ class EMailAddressForm(FormRevMixin, ModelForm):
super(EMailAddressForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['local_part'].label = "Local part of the email"
self.fields['local_part'].help_text = "Can't contain @"
def clean_local_part(self):
return self.cleaned_data.get('local_part').lower()
def clean_local_part(self):
return self.cleaned_data.get('local_part').lower()
@ -646,6 +649,12 @@ class EmailSettingsForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
else:
raise forms.ValidationError("Vous ne pouvez pas utiliser une addresse {}".format(OptionalUser.objects.first().local_email_domain))
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()
else:
raise forms.ValidationError("Vous ne pouvez pas utiliser une addresse {}".format(OptionalUser.objects.first().local_email_domain))
class Meta:
model = User
fields = ['email','local_email_enabled', 'local_email_redirect']