diff --git a/gestion/tools/list_droits.py b/gestion/tools/list_droits.py index 4113c20f..7951a113 100755 --- a/gestion/tools/list_droits.py +++ b/gestion/tools/list_droits.py @@ -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)