From 637fc9141382d4915a9bd09c5fa08311e716826b Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Tue, 30 Jul 2019 12:52:45 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E5=AF=86=E7=A0=81=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=EF=BC=88=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=9C=AA=E8=BF=87=E6=9C=9F=E7=94=A8=E6=88=B7&=E6=9C=89?= =?UTF-8?q?=E6=95=88=E7=94=A8=E6=88=B7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/models/user.py | 2 +- apps/users/tasks.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/users/models/user.py b/apps/users/models/user.py index 23587b1f1..a6cdf9f0e 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -111,7 +111,7 @@ class AuthMixin: @property def password_will_expired(self): - if self.is_local and self.password_expired_remain_days < 5: + if self.is_local and 0 <= self.password_expired_remain_days < 5: return True return False diff --git a/apps/users/tasks.py b/apps/users/tasks.py index ca8ea73da..ab025cae3 100644 --- a/apps/users/tasks.py +++ b/apps/users/tasks.py @@ -20,13 +20,13 @@ logger = get_logger(__file__) def check_password_expired(): users = User.objects.exclude(role=User.ROLE_APP) for user in users: + if not user.is_valid: + continue if not user.password_will_expired: continue - send_password_expiration_reminder_mail(user) - logger.info("The user {} password expires in {} days".format( - user, user.password_expired_remain_days) - ) + msg = "The user {} password expires in {} days" + logger.info(msg.format(user, user.password_expired_remain_days)) @shared_task