mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
Improve comments for User clean methods
This commit is contained in:
parent
dc67ed5298
commit
5eb89e85ba
1 changed files with 4 additions and 3 deletions
|
@ -1330,8 +1330,9 @@ class User(
|
|||
raise ValidationError(_("This username is already used."))
|
||||
|
||||
def clean_email(self, *args, **kwargs):
|
||||
# Allow empty emails if the user had an empty email before
|
||||
if not self.email and (self.__original_email or not self.pk):
|
||||
# Allow empty emails only if the user had an empty email before
|
||||
is_created = not self.pk
|
||||
if not self.email and (self.__original_email or is_created):
|
||||
raise forms.ValidationError(
|
||||
_("Email field cannot be empty.")
|
||||
)
|
||||
|
@ -1346,9 +1347,9 @@ class User(
|
|||
)
|
||||
|
||||
def clean(self, *args, **kwargs):
|
||||
super(User, self).clean(*args, **kwargs)
|
||||
"""Check if this pseudo is already used by any mailalias.
|
||||
Better than raising an error in post-save and catching it"""
|
||||
super(User, self).clean(*args, **kwargs)
|
||||
self.clean_pseudo(*args, **kwargs)
|
||||
self.clean_email(*args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue