8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 15:12:25 +00:00

Case of non existant email (legacy accounts)

This commit is contained in:
Gabriel Detraz 2020-03-23 12:46:10 +01:00
parent 2374a2b4b8
commit ad2c1e3d26

View file

@ -144,14 +144,17 @@ class UserCreationForm(FormRevMixin, forms.ModelForm):
super(UserCreationForm, self).__init__(*args, prefix=prefix, **kwargs) super(UserCreationForm, self).__init__(*args, prefix=prefix, **kwargs)
def clean_email(self): def clean_email(self):
if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get( if self.cleaned_data.get("email"):
"email" if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get(
): "email"
return self.cleaned_data.get("email").lower() ):
else: return self.cleaned_data.get("email").lower()
raise forms.ValidationError( else:
_("You can't use an internal address as your external address.") raise forms.ValidationError(
) _("You can't use a {} address.").format(
OptionalUser.objects.first().local_email_domain
)
)
class Meta: class Meta:
model = Adherent model = Adherent
@ -349,16 +352,17 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
) )
def clean_email(self): def clean_email(self):
if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get( if self.cleaned_data.get("email"):
"email" if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get(
): "email"
return self.cleaned_data.get("email").lower() ):
else: return self.cleaned_data.get("email").lower()
raise forms.ValidationError( else:
_("You can't use a {} address.").format( raise forms.ValidationError(
OptionalUser.objects.first().local_email_domain _("You can't use a {} address.").format(
OptionalUser.objects.first().local_email_domain
)
) )
)
def clean_telephone(self): def clean_telephone(self):
"""Verifie que le tel est présent si 'option est validée """Verifie que le tel est présent si 'option est validée
@ -756,16 +760,17 @@ class EmailSettingsForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
self.fields["local_email_enabled"].label = _("Use local emails") self.fields["local_email_enabled"].label = _("Use local emails")
def clean_email(self): def clean_email(self):
if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get( if self.cleaned_data.get("email"):
"email" if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get(
): "email"
return self.cleaned_data.get("email").lower() ):
else: return self.cleaned_data.get("email").lower()
raise forms.ValidationError( else:
_("You can't use a {} address.").format( raise forms.ValidationError(
OptionalUser.objects.first().local_email_domain _("You can't use a {} address.").format(
OptionalUser.objects.first().local_email_domain
)
) )
)
class Meta: class Meta:
model = User model = User