diff --git a/users/forms.py b/users/forms.py index 5669b155..c9f97508 100644 --- a/users/forms.py +++ b/users/forms.py @@ -368,6 +368,8 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): label=_("Force the move?"), initial=False, required=False ) + should_send_confirmation_email = False + def clean_email(self): if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get( "email" @@ -398,18 +400,19 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): def save(self, commit=True): """On met à jour l'état de l'utilisateur en fonction de son mail""" - user = super(AdherentForm, self).save(commit=False) + user = super(AdherentForm, self).save(commit=commit) if user.email != self.initial["email"]: # Send a confirmation email if user.state in [User.STATE_ACTIVE, User.STATE_DISABLED, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED]: user.state = User.STATE_EMAIL_NOT_YET_CONFIRMED - user.confirm_email_address_mail() + self.should_send_confirmation_email = True - # Always keep the oldest change date - if user.email_change_date is None: - user.email_change_date = timezone.now() + # Always keep the oldest change date + if user.email_change_date is None: + user.email_change_date = timezone.now() + user.save() return user diff --git a/users/models.py b/users/models.py index 8671fba0..48c91be9 100755 --- a/users/models.py +++ b/users/models.py @@ -226,7 +226,7 @@ class User( shortcuts_enabled = models.BooleanField( verbose_name=_("enable shortcuts on Re2o website"), default=True ) - email_change_date = None + email_change_date = models.DateTimeField(default=None, null=True) USERNAME_FIELD = "pseudo" REQUIRED_FIELDS = ["surname", "email"] @@ -795,6 +795,7 @@ class User( req.type = Request.EMAIL req.user = self req.save() + template = loader.get_template("users/email_confirmation_request") context = { "name": req.user.get_full_name(), diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index cb8358a8..2cbfe9ce 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -39,35 +39,23 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %} -