scripts/gestion/tools/list_droits.py
Valentin Samir 225ee9c248 [list_droits] Un peu de trie et pas de liste de droits hardcodé
On affiche aussi l'année d'arrivé de l'adhérent
2013-09-21 14:34:55 +02:00

35 lines
733 B
Python
Executable file

#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap, decode
db = crans_ldap()
txts = []
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 (%s)' % (adh.Nom(), adh.historique()[0].split(' ', 1)[0].split('/',2)[-1]))
noms.sort()
txt += u' %s' % '\n '.join(noms)
txts.append(txt)
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)