List_droits passe à lc_ldap

This commit is contained in:
Gabriel Detraz 2015-08-17 13:50:55 +02:00
parent 09a720b827
commit 62d9379f03

View file

@ -1,18 +1,17 @@
#! /usr/bin/env python #!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys from lc_ldap import shortcuts
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap, decode ldap = shortcuts.lc_ldap_readonly()
db = crans_ldap()
txts = [] txts = []
adhs=db.search('droits=*')['adherent'] adhs = ldap.search(u"droits=*")
droits={} droits={}
for adh in adhs: for adh in adhs:
for droit in adh.droits(): for droit in adh['droits']:
droit = unicode(droit)
droits[droit] = droits.get(droit, []) + [adh] droits[droit] = droits.get(droit, []) + [adh]
d=droits.keys() d=droits.keys()
@ -25,8 +24,7 @@ for droit in d:
txt = '%s\n' % droit txt = '%s\n' % droit
for adh in adhs : for adh in adhs :
noms.append(u'%s (%s)' % (adh.Nom(), adh.historique()[0].split(' ', 1)[0].split('/',2)[-1])) noms.append(u'%s %s (%s)' % (adh['prenom'][0],adh['nom'][0],adh['historique'][0].split()[0].split('/',2)[-1]))
noms.sort() noms.sort()
txt += u' %s' % '\n '.join(noms) txt += u' %s' % '\n '.join(noms)