From c944fbb917c464708e6d9b40fafa89a999d9c44d Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 20 Nov 2016 16:53:59 +0100 Subject: [PATCH] Activation de la synchro ldap users --- cotisations/models.py | 8 ++++---- machines/models.py | 4 ++-- users/models.py | 41 +++++++++++++++++++++++++++++++---------- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/cotisations/models.py b/cotisations/models.py index 6be735f7..59421649 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -34,12 +34,12 @@ class Facture(models.Model): def facture_post_save(sender, **kwargs): facture = kwargs['instance'] user = facture.user - #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) @receiver(post_delete, sender=Facture) def facture_post_delete(sender, **kwargs): user = kwargs['instance'].user - #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) class Vente(models.Model): PRETTY_NAME = "Ventes effectuées" @@ -68,14 +68,14 @@ def vente_post_save(sender, **kwargs): vente = kwargs['instance'] if vente.iscotisation: user = vente.facture.user - #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) @receiver(post_delete, sender=Vente) def vente_post_delete(sender, **kwargs): vente = kwargs['instance'] if vente.iscotisation: user = vente.facture.user - #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) class Article(models.Model): PRETTY_NAME = "Articles en vente" diff --git a/machines/models.py b/machines/models.py index 764247ab..29e126aa 100644 --- a/machines/models.py +++ b/machines/models.py @@ -129,9 +129,9 @@ class IpList(models.Model): @receiver(post_save, sender=Interface) def interface_post_save(sender, **kwargs): user = kwargs['instance'].machine.user - #user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) + user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) @receiver(post_delete, sender=Interface) def interface_post_delete(sender, **kwargs): user = kwargs['instance'].machine.user - #user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) + user.ldap_sync(base=False, access_refresh=False, mac_refresh=True) diff --git a/users/models.py b/users/models.py index bb13f6cc..5a9b326f 100644 --- a/users/models.py +++ b/users/models.py @@ -257,7 +257,7 @@ class User(AbstractBaseUser): user_ldap.mail = self.email user_ldap.given_name = str(self.surname).lower() + '_' + str(self.name).lower()[:3] user_ldap.gid = LDAP['user_gid'] - user_ldap.user_password = self.password + user_ldap.user_password = self.password[:6] + self.password[7:] user_ldap.sambat_nt_password = self.pwd_ntlm if self.shell: user_ldap.login_shell = self.shell.shell @@ -277,15 +277,15 @@ class User(AbstractBaseUser): def __str__(self): return self.pseudo -#@receiver(post_save, sender=User) -#def user_post_save(sender, **kwargs): -# user = kwargs['instance'] - #user.ldap_sync(base=True, access_refresh=True, mac_refresh=False) +@receiver(post_save, sender=User) +def user_post_save(sender, **kwargs): + user = kwargs['instance'] + user.ldap_sync(base=True, access_refresh=True, mac_refresh=False) @receiver(post_delete, sender=User) def user_post_delete(sender, **kwargs): user = kwargs['instance'] - #user.ldap_del() + user.ldap_del() class ServiceUser(AbstractBaseUser): PRETTY_NAME = "Utilisateurs de service" @@ -339,12 +339,12 @@ class Right(models.Model): @receiver(post_save, sender=Right) def right_post_save(sender, **kwargs): right = kwargs['instance'].right - #right.ldap_sync() + right.ldap_sync() @receiver(post_delete, sender=Right) def right_post_delete(sender, **kwargs): right = kwargs['instance'].right - #right.ldap_sync() + right.ldap_sync() class School(models.Model): PRETTY_NAME = "Etablissements enregistrés" @@ -383,12 +383,12 @@ class ListRight(models.Model): @receiver(post_save, sender=ListRight) def listright_post_save(sender, **kwargs): right = kwargs['instance'] - #right.ldap_sync() + right.ldap_sync() @receiver(post_delete, sender=ListRight) def listright_post_delete(sender, **kwargs): right = kwargs['instance'] - #right.ldap_del() + right.ldap_del() class ListShell(models.Model): PRETTY_NAME = "Liste des shells disponibles" @@ -409,6 +409,16 @@ class Ban(models.Model): def __str__(self): return str(self.user) + ' ' + str(self.raison) +@receiver(post_save, sender=Ban) +def ban_post_save(sender, **kwargs): + ban = kwargs['instance'] + user = ban.user + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + +@receiver(post_delete, sender=Ban) +def ban_post_delete(sender, **kwargs): + user = kwargs['instance'].user + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) class Whitelist(models.Model): PRETTY_NAME = "Liste des accès gracieux" @@ -421,6 +431,17 @@ class Whitelist(models.Model): def __str__(self): return str(self.user) + ' ' + str(self.raison) +@receiver(post_save, sender=Whitelist) +def whitelist_post_save(sender, **kwargs): + whitelist = kwargs['instance'] + user = whitelist.user + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + +@receiver(post_delete, sender=Whitelist) +def whitelist_post_delete(sender, **kwargs): + user = kwargs['instance'].user + user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + class Request(models.Model): PASSWD = 'PW' EMAIL = 'EM'