From c71c41fea8149f26b037ab484d7e43454739f034 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 17 Apr 2020 15:16:26 +0200 Subject: [PATCH] Notify users of suspension when they failed to confirm their email --- .../commands/disable_emailnotyetconfirmed.py | 1 + users/models.py | 18 +++++++++++++++++ users/templates/users/email_disable_notif | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 users/templates/users/email_disable_notif diff --git a/users/management/commands/disable_emailnotyetconfirmed.py b/users/management/commands/disable_emailnotyetconfirmed.py index e6de32f3..89dd3e86 100644 --- a/users/management/commands/disable_emailnotyetconfirmed.py +++ b/users/management/commands/disable_emailnotyetconfirmed.py @@ -41,4 +41,5 @@ class Command(BaseCommand): for user in users_to_disable: user.state = User.STATE_DISABLED + user.notif_disable() user.save() diff --git a/users/models.py b/users/models.py index 6b570337..e64db5d1 100755 --- a/users/models.py +++ b/users/models.py @@ -895,6 +895,24 @@ class User( ) return + def notif_disable(self): + """Envoi un mail de notification informant que l'adresse mail n'a pas été confirmée""" + template = loader.get_template("users/email_disable_notif") + context = { + "name": self.get_full_name(), + "asso_name": AssoOption.get_cached_value("name"), + "asso_email": AssoOption.get_cached_value("contact"), + "site_name": GeneralOption.get_cached_value("site_name"), + } + send_mail( + "Suspension automatique / Automatic suspension", + template.render(context), + GeneralOption.get_cached_value("email_from"), + [self.email], + fail_silently=False, + ) + return + def set_password(self, password): """ A utiliser de préférence, set le password en hash courrant et dans la version ntlm""" diff --git a/users/templates/users/email_disable_notif b/users/templates/users/email_disable_notif new file mode 100644 index 00000000..5b2a90e0 --- /dev/null +++ b/users/templates/users/email_disable_notif @@ -0,0 +1,20 @@ +Bonjour {{ name }}, + +Votre connexion a été automatiquement suspendue car votre adresse mail n'a pas été confirmée. Vous pouvez renvoyer un mail de confirmation sur votre compte {{ site_name }} pour réactiver votre connexion. + +Pour de plus amples renseignements, contactez {{ asso_name }} à l'adresse {{ asso_mail }}. + +Respectueusement, +L'équipe de {{ asso_name }}. + +--- + +Hello {{ name }}, + +Your connection has automatically been suspended because you have not confirmed your email address. You can ask for a new confirmation email to be sent on your profil at {{ site_name }} to enable your connection. + + +For more information, contactez {{ asso_name }} at {{ asso_mail }}. + +Regards, +The {{ asso_name }} team.