Passage de menage cableur à lc_ldap
This commit is contained in:
parent
94ee83b86a
commit
c34ebc5177
1 changed files with 31 additions and 32 deletions
|
@ -1,9 +1,8 @@
|
|||
#! /usr/bin/env python
|
||||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
# Copyright (C) Stéphane Glondu, Alexandre Bos
|
||||
# Copyright (C) Stéphane Glondu, Alexandre Bos, et autres
|
||||
# Licence : GPLv2
|
||||
|
||||
__doc__ = u"""Ce script permet de faire le menages parmis les câbleurs qui ne
|
||||
|
@ -21,16 +20,14 @@ Les commandes sont :
|
|||
|
||||
|
||||
import sys, os, re
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
import config
|
||||
from email_tools import send_email, parse_mail_template
|
||||
import gestion.config
|
||||
|
||||
# Fonctions d'affichage
|
||||
from affich_tools import coul, tableau, prompt, cprint
|
||||
from gestion.affich_tools import coul, tableau, prompt, cprint
|
||||
|
||||
# Importation de la base de données
|
||||
from ldap_crans import crans_ldap, ann_scol
|
||||
db = crans_ldap()
|
||||
from lc_ldap import shortcuts
|
||||
ldap = shortcuts.lc_ldap_admin()
|
||||
|
||||
def _controle_interactif_adherents(liste):
|
||||
"""
|
||||
|
@ -50,26 +47,28 @@ def _controle_interactif_adherents(liste):
|
|||
nb = 0
|
||||
for a in liste:
|
||||
ok = prompt(u'[%3d] %s, %s (%s) ?'
|
||||
% (restant, a.nom(), a.prenom(), a.id()), 'n', '').lower()
|
||||
% (restant, a['nom'][0], a['prenom'][0], a['aid'][0]), 'n', '').lower()
|
||||
restant -= 1
|
||||
if ok == 'o':
|
||||
modifiable = db.search('aid=%s' % a.id(), 'w')['adherent'][0]
|
||||
if modifiable._modifiable:
|
||||
modifiable.droits([])
|
||||
cprint(modifiable.save())
|
||||
else:
|
||||
cprint(u'Adhérent %s locké, réessayer plus tard' % modifiable.Nom(), 'rouge')
|
||||
modifiable = ldap.search(u'aid=%s' % a['aid'][0], mode='rw')[0]
|
||||
try:
|
||||
with modifiable as adh:
|
||||
adh['droits'].remove(u'Cableur')
|
||||
adh.history_gen()
|
||||
adh.save()
|
||||
cprint(u'Droits cableurs retirés', 'rouge')
|
||||
except:
|
||||
cprint(u'Adhérent %s locké, réessayer plus tard' % modifiable['nom'][0], 'rouge')
|
||||
elif ok != 'n':
|
||||
cprint(u'Arrêt du contrôle %s des membres actifs' % explicite, 'rouge')
|
||||
break
|
||||
|
||||
def candidats():
|
||||
todo_list1 = db.search('droits=*')['adherent']
|
||||
todo_list1 = ldap.search(u'droits=cableur')
|
||||
todo_list = []
|
||||
for adh in todo_list1:
|
||||
if adh.droitsGeles():
|
||||
if not adh.paiement_ok():
|
||||
todo_list.append(adh)
|
||||
todo_list.sort(lambda x, y: cmp((x.nom(), x.prenom()), (y.nom(), y.prenom())))
|
||||
return todo_list
|
||||
|
||||
def lister():
|
||||
|
@ -80,7 +79,7 @@ def lister():
|
|||
print "Liste des câbleur dont la cotisation n'est pas à jour."
|
||||
print
|
||||
for adh in todo_list:
|
||||
print adh.prenom() + " " + adh.nom()
|
||||
print unicode(adh['prenom'][0]) + u" " + unicode(adh['nom'][0])
|
||||
print
|
||||
print "total : " + str(len(todo_list))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue