Passage aux adhésions glissantes (partie 2/2, lc_ldap)
This commit is contained in:
parent
6880051943
commit
7f1ffbeed5
7 changed files with 180 additions and 30 deletions
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
from gestion.affich_tools import coul, tableau
|
||||
from gestion.affichage import style, tableau
|
||||
import importlib
|
||||
import time
|
||||
import ldap
|
||||
import sys
|
||||
import gestion.config as config
|
||||
|
||||
# Import inutile, mais on en a besoin pour que le
|
||||
# script continue à fonctionner.
|
||||
|
@ -35,9 +36,9 @@ def prise_etat(chbre):
|
|||
# fonction prise_etat propre à lc_ldap, pour
|
||||
# ne plus en avoir besoin ci-après.
|
||||
gestion.whos = try_import(u"gestion.whos")
|
||||
gestion.whos.coul = coul
|
||||
gestion.whos.style = style
|
||||
if chbre=="????":
|
||||
return coul("Chambre invalide", "violet")
|
||||
return style("Chambre invalide", "violet")
|
||||
return gestion.whos.prise_etat(chbre)[0]
|
||||
|
||||
def timeformat(t, format):
|
||||
|
@ -50,13 +51,13 @@ def blacklists(l):
|
|||
fin=b['fin'] if b['fin'] == '-' else time.strftime("%d/%m/%Y %H:%M", time.localtime(b['fin']))
|
||||
couleur='rouge' if b['actif'] else None
|
||||
if debut != '-' and fin !='-':
|
||||
bl.append(coul(u"du %s au %s : %s [%s]" % (debut, fin, b['type'], b['comm']), couleur))
|
||||
bl.append(style(u"du %s au %s : %s [%s]" % (debut, fin, b['type'], b['comm']), couleur))
|
||||
elif debut != '-':
|
||||
bl.append(coul(u"À partir du %s : %s [%s]" % (debut, b['type'], b['comm']), couleur))
|
||||
bl.append(style(u"À partir du %s : %s [%s]" % (debut, b['type'], b['comm']), couleur))
|
||||
elif fin != '-':
|
||||
bl.append(coul(u"Jusqu'au %s : %s [%s]" % (fin, b['type'], b['comm']), couleur))
|
||||
bl.append(style(u"Jusqu'au %s : %s [%s]" % (fin, b['type'], b['comm']), couleur))
|
||||
else:
|
||||
bl.append(coul(u"%s [%s]" % (b['type'], b['comm']), couleur))
|
||||
bl.append(style(u"%s [%s]" % (b['type'], b['comm']), couleur))
|
||||
return bl
|
||||
|
||||
def split(str, *arg):
|
||||
|
@ -90,19 +91,19 @@ def const_of_mac(mac):
|
|||
|
||||
templateEnv=None
|
||||
def template(dialog=False):
|
||||
global templateEnv, coul, tableau
|
||||
global templateEnv, style, tableau
|
||||
if not templateEnv:
|
||||
# un import paresseux, comme ça, pas la peine d'installer jinja2 sur les machines où il n'y en a pas besoin
|
||||
import jinja2
|
||||
oldcoul = coul
|
||||
oldstyle = style
|
||||
oldtableau = tableau
|
||||
tableau = lambda *args,**kwargs: oldtableau(*args,dialog=dialog,**kwargs)
|
||||
coul = lambda *args,**kwargs:oldcoul(*args,dialog=dialog,**kwargs)
|
||||
style = lambda *args,**kwargs:oldstyle(*args,dialog=dialog,**kwargs)
|
||||
template_path = '/usr/scripts/lc_ldap/printing/templates/'
|
||||
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
|
||||
templateEnv = jinja2.Environment( loader=templateLoader, trim_blocks=True )
|
||||
templateEnv.add_extension('jinja2.ext.do')
|
||||
templateEnv.filters['coul'] = coul
|
||||
templateEnv.filters['coul'] = style
|
||||
templateEnv.filters['blacklists'] = blacklists
|
||||
templateEnv.filters['prise_etat'] = prise_etat
|
||||
templateEnv.filters['timeformat'] = timeformat
|
||||
|
@ -130,7 +131,7 @@ def list_machines(machines, width=None):
|
|||
def list_factures(factures, width=None):
|
||||
return tableau([
|
||||
[f['fid'][0], f['modePaiement'][0],
|
||||
coul("OK", "vert") if f.get('recuPaiement', []) else coul("NON", "rouge"),
|
||||
style("OK", "vert") if f.get('recuPaiement', []) else style("NON", "rouge"),
|
||||
' '.join(attr['code'] for attr in f.get('article',[])),
|
||||
u"%s€" % sum([float(a['pu'])*int(a['nombre']) for a in f.get('article',[])])
|
||||
] for f in factures],
|
||||
|
@ -143,8 +144,8 @@ def list_adherents(adherents, width=None):
|
|||
return tableau([
|
||||
[a['aid'][0],
|
||||
u' '.join(unicode(i) for i in a['prenom'] + a['nom']),
|
||||
a['chbre'][0], coul('o', 'vert') if a.paiement_ok() else coul('n', 'rouge'),
|
||||
coul('o', 'vert') if a.carte_ok() else coul('n', 'rouge'),
|
||||
a['chbre'][0], style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'),
|
||||
style('o', 'vert') if a.carte_ok() else style('n', 'rouge'),
|
||||
u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines())
|
||||
] for a in adherents ],
|
||||
titre = [u'aid', u'Prénom Nom', u'Chbre', u'P', u'C', u'Machines'],
|
||||
|
@ -156,7 +157,7 @@ def list_clubs(clubs, width=None):
|
|||
return tableau([
|
||||
[a['cid'][0],
|
||||
u' '.join(unicode(i) for i in a['nom']),
|
||||
a['chbre'][0], coul('o', 'vert') if a.paiement_ok() else coul('n', 'rouge'),
|
||||
a['chbre'][0], style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'),
|
||||
u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines())
|
||||
] for a in clubs ],
|
||||
titre = [u'cid', u'Nom', u'Chbre', u'P', u'Machines'],
|
||||
|
@ -168,14 +169,39 @@ def proprio(proprio, params):
|
|||
params['o']=proprio
|
||||
etat_administratif=[]
|
||||
if proprio.paiement_ok() and proprio.carte_ok():
|
||||
etat_administratif.append(coul(u"à jour", "vert"))
|
||||
etat_administratif.append(style(u"à jour", "vert"))
|
||||
if not proprio.carte_ok():
|
||||
etat_administratif.append(coul(u"manque carte d'étudiant", "violet"))
|
||||
etat_administratif.append(style(u"manque carte d'étudiant", "violet"))
|
||||
if not proprio.paiement_ok():
|
||||
etat_administratif.append(coul(u"cotisation non réglée", "violet"))
|
||||
etat_administratif.append(style(u"cotisation non réglée", "violet"))
|
||||
if proprio.fin_adhesion() >= time.time():
|
||||
adh = style(u"Adhésion jusqu'au %s" % (time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(proprio.fin_adhesion())),), "vert")
|
||||
elif config.ann_scol in proprio['paiement']:
|
||||
adh = style(u"Adhésion pour la période %s-%s ok." % (config.ann_scol, config.ann_scol+1), "vert")
|
||||
elif proprio.paiement_ok():
|
||||
adh = style(u"Adhésion terminée, mais il y a un sursis.", 'orange')
|
||||
else:
|
||||
adh = style(u"Pas adhérent actuellement.", 'rouge')
|
||||
params["adh"] = adh
|
||||
if proprio.fin_connexion() >= time.time():
|
||||
conn = style(u"Connexion jusqu'au %s" % (time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(proprio.fin_connexion())),), "vert")
|
||||
elif config.ann_scol in proprio['paiement']:
|
||||
conn = style(u"Connexion pour la période %s-%s ok." % (config.ann_scol, config.ann_scol+1), "vert")
|
||||
elif proprio.paiement_ok():
|
||||
conn = style(u"Connexion terminée, mais il y a un sursis.", 'orange')
|
||||
else:
|
||||
conn = style(u"Pas connecté actuellement.", 'rouge')
|
||||
params["conn"] = conn
|
||||
if proprio.get('carteEtudiant', []):
|
||||
cetud = style(u"Carte d'étudiant fournie.", 'vert')
|
||||
elif proprio.sursis_carte() or proprio.carte_ok():
|
||||
cetud = style(u"Carte d'étudiant non fournie, mais en sursis.", 'orange')
|
||||
else:
|
||||
cetud = style(u"Pas de carte d'étudiant")
|
||||
params["cetud"] = cetud
|
||||
params['etat_administratif']=etat_administratif
|
||||
if proprio["chbre"][0].value not in ["????", "EXT"]:
|
||||
params['brassage'] = coul("Cr@ns", "bleu") if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else coul("CROUS", "jaune")
|
||||
params['brassage'] = style("Cr@ns", "bleu") if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else style("CROUS", "jaune")
|
||||
|
||||
try:
|
||||
if proprio.machines():
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
{{"Chambre : "|coul('gras')}}{{o.chbre.0}} ({{o.chbre.0|string|prise_etat}})
|
||||
{% endif %}
|
||||
{{"Études : "|coul('gras')}}{{o.etudes|join(' ')}}
|
||||
{{"Cotisation payée pour les années : "|coul('gras')}}{{o.paiement|join(' ')}} {% if o.get('controle', []) and 'p' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||
{{"Carte d'étudiant fournie pour les années : "|coul('gras')}}{{o.carteEtudiant|join(' ')}} {% if o.get('controle', []) and 'c' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||
{{adh}} {% if o.get('controle', []) and 'p' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||
|
||||
{{conn}} {% if o.get('controle', []) and 'p' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||
|
||||
{{cetud}} {% if o.get('controle', []) and 'c' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||
|
||||
{% endblock%}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
{{"Imprimeurs : "|coul('gras')}}{% for i in o.imprimeurClub %}{{i.value.prenom|join(' ')}} {{i.value.nom|join(' ')}} ({{i.value.aid|join(' ')}}) {% endfor%}
|
||||
|
||||
{{"Local : "|coul('gras')}}{{o.chbre.0}} ({{o.chbre.0|string|prise_etat}})
|
||||
{{"Charte signée pour les années scolaires : "|coul('gras')}}{{o.paiement|join(' ')}}
|
||||
{{adh}}
|
||||
{% endblock%}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue