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
9fe4313540
commit
8b75900103
2 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue