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

Make AdherentCreationForm code clearer

This commit is contained in:
Jean-Romain Garnier 2020-04-17 20:41:02 +02:00 committed by Jean-Romain Garnier
parent f790dca202
commit 1ee4d91721
2 changed files with 4 additions and 5 deletions

View file

@ -502,11 +502,11 @@ class AdherentCreationForm(AdherentForm):
user = super(AdherentForm, self).save(commit=False)
is_set_password_allowed = OptionalUser.get_cached_value("allow_set_password_during_user_creation")
send_email = not is_set_password_allowed or self.cleaned_data.get("init_password_by_mail")
if not send_email:
set_passwd = is_set_password_allowed and not self.cleaned_data.get("init_password_by_mail")
if set_passwd:
user.set_password(self.cleaned_data["password1"])
user.should_send_password_reset_email = send_email
user.did_set_initial_passwd = set_passwd
user.save()
return user

View file

@ -124,8 +124,7 @@ def new_user(request):
is_set_password_allowed = OptionalUser.get_cached_value("allow_set_password_during_user_creation")
if user.is_valid():
# Use "is False" so that if None, the email is sent
if is_set_password_allowed and user.should_send_password_reset_email:
if user.did_set_initial_passwd:
user.send_confirm_email_if_necessary(request)
messages.success(
request,