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 -*-
import sys
sys.path.append('/usr/scripts/gestion')
from lc_ldap import shortcuts
from ldap_crans import crans_ldap, decode
ldap = shortcuts.lc_ldap_readonly()
db = crans_ldap()
txts = []
adhs=db.search('droits=*')['adherent']
adhs = ldap.search(u"droits=*")
droits={}
for adh in adhs:
for droit in adh.droits():
for droit in adh['droits']:
droit = unicode(droit)
droits[droit] = droits.get(droit, []) + [adh]
d=droits.keys()
@ -20,16 +19,15 @@ d.sort()
for droit in d:
adhs = droits[droit]
noms = []
txt = '%s\n' % droit
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()
txt += u' %s' % '\n '.join(noms)
txts.append(txt)
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)