|
@@ -4,7 +4,9 @@ from __future__ import unicode_literals
|
|
from django.db import transaction
|
|
from django.db import transaction
|
|
from django.conf import settings
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
+
|
|
class CoinLdapSyncMixin(object):
|
|
class CoinLdapSyncMixin(object):
|
|
|
|
+
|
|
"""
|
|
"""
|
|
Ce mixin est à utiliser lorsqu'il s'agit de définir un modèle
|
|
Ce mixin est à utiliser lorsqu'il s'agit de définir un modèle
|
|
à synchroniser avec le LDAP. Le modèle doit définir les méthodes :
|
|
à synchroniser avec le LDAP. Le modèle doit définir les méthodes :
|
|
@@ -18,7 +20,6 @@ class CoinLdapSyncMixin(object):
|
|
raise NotImplementedError('Using CoinLdapSyncModel require '
|
|
raise NotImplementedError('Using CoinLdapSyncModel require '
|
|
'sync_to_ldap method being implemented')
|
|
'sync_to_ldap method being implemented')
|
|
|
|
|
|
-
|
|
|
|
def delete_from_ldap(self, *args, **kwargs):
|
|
def delete_from_ldap(self, *args, **kwargs):
|
|
raise NotImplementedError('Using CoinLdapSyncModel require '
|
|
raise NotImplementedError('Using CoinLdapSyncModel require '
|
|
'delete_from_ldap method being implemented')
|
|
'delete_from_ldap method being implemented')
|
|
@@ -29,7 +30,8 @@ class CoinLdapSyncMixin(object):
|
|
creation = (self.pk == None)
|
|
creation = (self.pk == None)
|
|
|
|
|
|
# Récupère les champs mis à jour si cela est précisé
|
|
# Récupère les champs mis à jour si cela est précisé
|
|
- update_fields = kwargs['update_fields'] if 'update_fields' in kwargs else None
|
|
|
|
|
|
+ update_fields = kwargs[
|
|
|
|
+ 'update_fields'] if 'update_fields' in kwargs else None
|
|
|
|
|
|
# Sauvegarde en base de donnée (mais sans commit, cf decorator)
|
|
# Sauvegarde en base de donnée (mais sans commit, cf decorator)
|
|
super(CoinLdapSyncMixin, self).save(*args, **kwargs)
|
|
super(CoinLdapSyncMixin, self).save(*args, **kwargs)
|
|
@@ -39,7 +41,8 @@ class CoinLdapSyncMixin(object):
|
|
# commit
|
|
# commit
|
|
if settings.LDAP_ACTIVATE:
|
|
if settings.LDAP_ACTIVATE:
|
|
try:
|
|
try:
|
|
- self.sync_to_ldap(creation=creation,update_fields=update_fields)
|
|
|
|
|
|
+ self.sync_to_ldap(
|
|
|
|
+ creation=creation, update_fields=update_fields)
|
|
except:
|
|
except:
|
|
raise
|
|
raise
|
|
|
|
|