[controle_tresorier3] Nouveau script de controle pour les tresoriers
Ignore-this: 918dc9673d412ec5b45afa7bb2e69ea8 Fait pour controler de facon encore plus rapide, en tapant une ligne genre controle_tresorier3 nom=blockelet+p 2190c 1375p ... Experimente ce soir, ca marche vraiment bien ;) darcs-hash:20111021224738-ddb99-4794569e901e4007862c1a6c58324db9344769d6.gz
This commit is contained in:
parent
a19775bc1e
commit
b9830c171b
2 changed files with 93 additions and 0 deletions
91
admin/controle_tresorier3.py
Executable file
91
admin/controle_tresorier3.py
Executable file
|
@ -0,0 +1,91 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2011 Michel Blockelet
|
||||||
|
# Licence : GPLv3
|
||||||
|
|
||||||
|
u"""Ce script permet aux trésoriers d'effectuer les contrôles en spécifiant
|
||||||
|
chaque adhérent par une expression de recherche et les contrôles à effectuer
|
||||||
|
sur cette personne.
|
||||||
|
|
||||||
|
Exemple :
|
||||||
|
controle_tresorier3.py nom=blockelet+pc 2190c
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append('/usr/scripts/gestion')
|
||||||
|
from config import ann_scol
|
||||||
|
from ldap_crans import crans_ldap
|
||||||
|
from affich_tools import coul
|
||||||
|
|
||||||
|
db = crans_ldap()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
# Aide
|
||||||
|
if sys.argv[1] == '-h':
|
||||||
|
print __doc__
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print coul('=== Mode non-interactif ===', 'vert')
|
||||||
|
for act in sys.argv[1:]:
|
||||||
|
# Deux formats
|
||||||
|
if '+' in act:
|
||||||
|
# [recherche]+[contrôle] : nom=blockelet+pc
|
||||||
|
[sexpr, contr] = act.split('+')
|
||||||
|
else:
|
||||||
|
# [aid][contrôle] : 1240pc
|
||||||
|
contr = ('p' if 'p' in act else '') + ('c' if 'c' in act else '')
|
||||||
|
sexpr = "aid=%s" % act.replace('p', '').replace('c', '')
|
||||||
|
|
||||||
|
# Recherche
|
||||||
|
try:
|
||||||
|
adhl = db.search(sexpr, 'w')['adherent']
|
||||||
|
except:
|
||||||
|
print coul(" *** Erreur de recherche : (%s)(+%s)" %
|
||||||
|
(sexpr, contr), 'rouge')
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(adhl) == 0:
|
||||||
|
print coul(" *** Aucun adhérent trouvé : (%s)(+%s)" %
|
||||||
|
(sexpr, contr), 'rouge')
|
||||||
|
continue
|
||||||
|
if len(adhl) > 1:
|
||||||
|
print coul(" *** Plusieurs adhérents trouvés : (%s)(+%s)" %
|
||||||
|
(sexpr, contr), 'rouge')
|
||||||
|
continue
|
||||||
|
adh = adhl[0]
|
||||||
|
if ann_scol not in adh.paiement():
|
||||||
|
print coul(" *** N'a pas adhéré cette année : (%s)(+%s)" %
|
||||||
|
(sexpr, contr), 'rouge')
|
||||||
|
continue
|
||||||
|
|
||||||
|
modif = False
|
||||||
|
|
||||||
|
# On regarde les contrôles à faire
|
||||||
|
newcontr = contr
|
||||||
|
if 'p' in adh.controle():
|
||||||
|
newcontr = newcontr.replace('p', '')
|
||||||
|
if 'c' in adh.controle():
|
||||||
|
newcontr = newcontr.replace('c', '')
|
||||||
|
|
||||||
|
print coul(" * %s (aid=%s) : %s +%s -> %s" % (adh.Nom(), adh.id(),
|
||||||
|
adh.controle(), contr, (newcontr if newcontr else '[rien]')),
|
||||||
|
'bleu')
|
||||||
|
|
||||||
|
# Si la carte n'est pas notée, on le fait
|
||||||
|
if ann_scol not in adh.carteEtudiant() and 'c' in contr:
|
||||||
|
print coul("Ajout de la carte", 'violet')
|
||||||
|
adh.carteEtudiant(ann_scol)
|
||||||
|
modif = True
|
||||||
|
|
||||||
|
# On fait les contrôles
|
||||||
|
if modif or newcontr != '':
|
||||||
|
if newcontr == 'pc' or newcontr == 'cp':
|
||||||
|
adh.controle('+p')
|
||||||
|
adh.controle('+c')
|
||||||
|
else:
|
||||||
|
adh.controle('+%s' % newcontr)
|
||||||
|
adh.save()
|
||||||
|
else:
|
||||||
|
print coul("Aucune modification", 'jaune')
|
2
respbats/controle_tresorier3
Executable file
2
respbats/controle_tresorier3
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#! /bin/sh
|
||||||
|
sudo -u respbats /usr/scripts/admin/controle_tresorier3.py $*
|
Loading…
Add table
Add a link
Reference in a new issue