mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Make AdherentCreationForm code clearer
This commit is contained in:
parent
f790dca202
commit
1ee4d91721
2 changed files with 4 additions and 5 deletions
|
@ -502,11 +502,11 @@ class AdherentCreationForm(AdherentForm):
|
||||||
user = super(AdherentForm, self).save(commit=False)
|
user = super(AdherentForm, self).save(commit=False)
|
||||||
|
|
||||||
is_set_password_allowed = OptionalUser.get_cached_value("allow_set_password_during_user_creation")
|
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")
|
set_passwd = is_set_password_allowed and not self.cleaned_data.get("init_password_by_mail")
|
||||||
if not send_email:
|
if set_passwd:
|
||||||
user.set_password(self.cleaned_data["password1"])
|
user.set_password(self.cleaned_data["password1"])
|
||||||
|
|
||||||
user.should_send_password_reset_email = send_email
|
user.did_set_initial_passwd = set_passwd
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,7 @@ def new_user(request):
|
||||||
is_set_password_allowed = OptionalUser.get_cached_value("allow_set_password_during_user_creation")
|
is_set_password_allowed = OptionalUser.get_cached_value("allow_set_password_during_user_creation")
|
||||||
|
|
||||||
if user.is_valid():
|
if user.is_valid():
|
||||||
# Use "is False" so that if None, the email is sent
|
if user.did_set_initial_passwd:
|
||||||
if is_set_password_allowed and user.should_send_password_reset_email:
|
|
||||||
user.send_confirm_email_if_necessary(request)
|
user.send_confirm_email_if_necessary(request)
|
||||||
messages.success(
|
messages.success(
|
||||||
request,
|
request,
|
||||||
|
|
Loading…
Reference in a new issue