From fe378e7909ad70e1927f814d48d0bde8ad0341ec Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 19 Jul 2018 20:46:12 +0200 Subject: [PATCH] Function for shadow expire --- users/models.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/users/models.py b/users/models.py index 4a10dd90..10ec4d8d 100644 --- a/users/models.py +++ b/users/models.py @@ -321,6 +321,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, si il n'est pas défini""" return self.shell or OptionalUser.get_cached_value('shell_default') + @cached_property + def get_shadow_expire(self): + """Return the shadow_expire value for the user""" + if self.state == self.STATE_DISABLED: + return str(0) + else: + return None + def end_adhesion(self): """ Renvoie la date de fin d'adhésion d'un user. Examine les objets cotisation""" @@ -522,10 +530,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, user_ldap.sambat_nt_password = self.pwd_ntlm.upper() if self.get_shell: user_ldap.login_shell = str(self.get_shell) - if self.state == self.STATE_DISABLED: - user_ldap.shadowexpire = str(0) - else: - user_ldap.shadowexpire = None + user_ldap.shadowexpire = self.get_shadow_expire if access_refresh: user_ldap.dialupAccess = str(self.has_access()) if mac_refresh: