From 241d2462c32a889482a54a1a7a24cb8c091c796a Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Fri, 27 Oct 2017 01:46:43 +0200 Subject: [PATCH] Si l'instance ldap_user existe pas on l'ajoute sans bruit --- users/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/users/models.py b/users/models.py index 68b80b25..81fd4aa8 100644 --- a/users/models.py +++ b/users/models.py @@ -545,12 +545,16 @@ class User(AbstractBaseUser): mail, password, shell, home access_refresh : synchronise le dialup_access notant si l'user a accès aux services - mac_refresh : synchronise les machines de l'user""" + mac_refresh : synchronise les machines de l'user + Si l'instance n'existe pas, on crée le ldapuser correspondant""" self.refresh_from_db() try: user_ldap = LdapUser.objects.get(uidNumber=self.uid_number) except LdapUser.DoesNotExist: user_ldap = LdapUser(uidNumber=self.uid_number) + base = True + access_refresh = True + mac_refresh = True if base: user_ldap.name = self.pseudo user_ldap.sn = self.pseudo @@ -574,7 +578,6 @@ class User(AbstractBaseUser): user_ldap.macs = [str(mac) for mac in Interface.objects.filter( machine__user=self ).values_list('mac_address', flat=True).distinct()] - user_ldap.save() def ldap_del(self):