diff --git a/gestion/tools/list_droits.py b/gestion/tools/list_droits.py index b050e3cb..4113c20f 100755 --- a/gestion/tools/list_droits.py +++ b/gestion/tools/list_droits.py @@ -9,15 +9,25 @@ from ldap_crans import crans_ldap, decode db = crans_ldap() txts = [] -for droit in [ u'Nounou', u'Apprenti', u'Moderateur', u'Cableur', u'Webradio' , u'Imprimeur', u'Bureau', u'Tresorier', u'Troll'] : - adhs = db.search('droits=%s' % droit)['adherent'] +adhs=db.search('droits=*')['adherent'] +droits={} +for adh in adhs: + for droit in adh.droits(): + droits[droit] = droits.get(droit, []) + [adh] + +d=droits.keys() +d.sort() + +for droit in d: + adhs = droits[droit] noms = [] txt = '%s\n' % droit for adh in adhs : - noms.append(u'%s' % adh.Nom()) - + noms.append(u'%s (%s)' % (adh.Nom(), adh.historique()[0].split(' ', 1)[0].split('/',2)[-1])) + + noms.sort() txt += u' %s' % '\n '.join(noms) txts.append(txt)