From 6b17d924ce309ee3d4b540e93891fbadc00cdbb9 Mon Sep 17 00:00:00 2001 From: Yoann Pietri Date: Sun, 15 Jul 2018 18:08:25 +0200 Subject: [PATCH] =?UTF-8?q?Affichage=20d'un=20message=20d'erreur=20si=20l'?= =?UTF-8?q?utilisateur=20n'est=20pas=20v=C3=A9rifi=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base.html | 3 +++ users/models.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/templates/base.html b/templates/base.html index d6b03798..c1e5cb9c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -172,6 +172,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+ {% if user.is_authenticated and user.verification_message %} +
{{user.verification_message}}
+ {% endif %} {# Display django.contrib.messages as Bootstrap alerts #} {% bootstrap_messages %}
diff --git a/users/models.py b/users/models.py index 378f6a5e..ae7dd4d1 100644 --- a/users/models.py +++ b/users/models.py @@ -618,6 +618,17 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, fail_silently=False ) return + + @property + def verification_message(self): + if(OptionalUser.get_cached_value('mail_verification') and not self.verified): + if(self.verification_deadline is not None): + message = 'Votre adresse mail n\'est pas vérifiée. Si vous ne vérifiez pas votre adresse mail, toute connexion sera intérrompu le ' + self.verification_deadline + else: + message = 'Votre adresse mail n\'est pas vérifiée.' + return message + else: + return False def autoregister_machine(self, mac_address, nas_type): """ Fonction appellée par freeradius. Enregistre la mac pour