|
@@ -8,13 +8,12 @@ from django.db.models import Q
|
|
|
from django.db.models.signals import pre_save
|
|
|
from django.dispatch import receiver
|
|
|
from django.contrib.auth.models import AbstractUser
|
|
|
+from django.conf import settings
|
|
|
from ldapdb.models.fields import CharField, IntegerField, ListField
|
|
|
from south.modelsinspector import add_ignored_fields
|
|
|
from coin.offers.models import OfferSubscription
|
|
|
from coin.mixins import CoinLdapSyncMixin
|
|
|
from coin import utils
|
|
|
-from django.contrib.auth.signals import user_logged_in
|
|
|
-from django.conf import settings
|
|
|
|
|
|
|
|
|
class Member(CoinLdapSyncMixin, AbstractUser):
|
|
@@ -83,7 +82,7 @@ class Member(CoinLdapSyncMixin, AbstractUser):
|
|
|
return '%s %s' % (self.first_name, self.last_name)
|
|
|
|
|
|
def get_short_name(self):
|
|
|
- return '%s' % self.username
|
|
|
+ return self.username
|
|
|
|
|
|
# Renvoie la date de fin de la dernière cotisation du membre
|
|
|
def end_date_of_membership(self):
|
|
@@ -176,10 +175,10 @@ class Member(CoinLdapSyncMixin, AbstractUser):
|
|
|
|
|
|
ldap_user.save()
|
|
|
|
|
|
- if creation:
|
|
|
- ldap_group = LdapGroup.objects.get(pk='coin')
|
|
|
- ldap_group.members.append(ldap_user.pk)
|
|
|
- ldap_group.save()
|
|
|
+ # if creation:
|
|
|
+ # ldap_group = LdapGroup.objects.get(pk='coin')
|
|
|
+ # ldap_group.members.append(ldap_user.pk)
|
|
|
+ # ldap_group.save()
|
|
|
|
|
|
def delete_from_ldap(self):
|
|
|
"""
|
|
@@ -188,13 +187,17 @@ class Member(CoinLdapSyncMixin, AbstractUser):
|
|
|
assert self.username, ('Can\'t delete from LDAP because missing '
|
|
|
'username value for the Member : %s' % self)
|
|
|
|
|
|
+ #Delete user from LDAP
|
|
|
+ ldap_user = LdapUser.objects.get(pk=self.username)
|
|
|
+ ldap_user.delete()
|
|
|
+
|
|
|
# Lorsqu'un membre est supprimé du SI, son utilisateur LDAP
|
|
|
# correspondant est sorti du groupe "coin" afin qu'il n'ait plus
|
|
|
# accès au SI
|
|
|
- ldap_group = LdapGroup.objects.get(pk='coin')
|
|
|
- if self.username in ldap_group.members:
|
|
|
- ldap_group.members.remove(self.username)
|
|
|
- ldap_group.save()
|
|
|
+ # ldap_group = LdapGroup.objects.get(pk='coin')
|
|
|
+ # if self.username in ldap_group.members:
|
|
|
+ # ldap_group.members.remove(self.username)
|
|
|
+ # ldap_group.save()
|
|
|
|
|
|
class Meta:
|
|
|
verbose_name = 'membre'
|
|
@@ -240,8 +243,7 @@ class MembershipFee(models.Model):
|
|
|
|
|
|
|
|
|
class LdapUser(ldapdb.models.Model):
|
|
|
- # TODO: déplacer ligne suivante dans settings.py
|
|
|
- base_dn = "ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
|
|
|
+ base_dn = settings.LDAP_USER_BASE_DN #"ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
|
|
|
object_classes = ['inetOrgPerson', 'organizationalPerson', 'person',
|
|
|
'top', 'posixAccount']
|
|
|
|
|
@@ -266,15 +268,9 @@ class LdapUser(ldapdb.models.Model):
|
|
|
|
|
|
|
|
|
class LdapGroup(ldapdb.models.Model):
|
|
|
- """
|
|
|
- Class for representing an LDAP group entry.
|
|
|
- """
|
|
|
- #TODO: config à externaliser
|
|
|
- # LDAP meta-data
|
|
|
- base_dn = "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
|
|
|
+ base_dn = settings.LDAP_GROUP_BASE_DN #"ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
|
|
|
object_classes = ['posixGroup']
|
|
|
|
|
|
- # posixGroup attributes
|
|
|
gid = IntegerField(db_column='gidNumber', unique=True)
|
|
|
name = CharField(db_column='cn', max_length=200, primary_key=True)
|
|
|
members = ListField(db_column='memberUid')
|