[printing] Affichage des liste de machines et factures sur un proprio
en même temps, on met une fonction pour lister les adherents. Je ne suis pas trop satisfait de ces fonctions de listing, mais je ne vois pas vraiement comment faire autrement.
This commit is contained in:
parent
3cf36346ab
commit
8bbcc3b035
3 changed files with 69 additions and 6 deletions
|
@ -71,4 +71,4 @@ def human_to_list(data):
|
||||||
return collapse(toprefix(prioritize(pypexpr().parseString("(%s)" % data).asList())))
|
return collapse(toprefix(prioritize(pypexpr().parseString("(%s)" % data).asList())))
|
||||||
|
|
||||||
def human_to_ldap(data):
|
def human_to_ldap(data):
|
||||||
return "(%s)" % toldapfilter(human_to_list(data))
|
return u"(%s)" % toldapfilter(human_to_list(data))
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/bin/bash /usr/scripts/python.sh
|
#!/bin/bash /usr/scripts/python.sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from gestion.affich_tools import coul
|
from gestion.affich_tools import coul, tableau
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import gestion.whos
|
import gestion.whos
|
||||||
import gestion.annuaires_pg
|
import gestion.annuaires_pg
|
||||||
|
|
||||||
|
@ -32,8 +31,8 @@ def telephone(l):
|
||||||
if len(str(t)) == 10:
|
if len(str(t)) == 10:
|
||||||
tel.append("%c%c.%c%c.%c%c.%c%c.%c%c" % tuple(map(ord, str(t))))
|
tel.append("%c%c.%c%c.%c%c.%c%c.%c%c" % tuple(map(ord, str(t))))
|
||||||
else:
|
else:
|
||||||
if t.startswith("00"):
|
if str(t).startswith("00"):
|
||||||
t="+%s" % t[2:]
|
t="+%s" % str(t)[2:]
|
||||||
tel.append(t)
|
tel.append(t)
|
||||||
return tel
|
return tel
|
||||||
|
|
||||||
|
@ -53,12 +52,46 @@ def template():
|
||||||
templateEnv.filters['timeformat'] = timeformat
|
templateEnv.filters['timeformat'] = timeformat
|
||||||
templateEnv.filters['split'] = split
|
templateEnv.filters['split'] = split
|
||||||
templateEnv.filters['telephone'] = telephone
|
templateEnv.filters['telephone'] = telephone
|
||||||
|
templateEnv.filters['tableau'] = tableau
|
||||||
return templateEnv
|
return templateEnv
|
||||||
|
|
||||||
def machine(machine, params):
|
def machine(machine, params):
|
||||||
params['o']=machine
|
params['o']=machine
|
||||||
return template().get_template("machine").render(params)
|
return template().get_template("machine").render(params)
|
||||||
|
|
||||||
|
|
||||||
|
def list_machines(machines):
|
||||||
|
return tableau([
|
||||||
|
[m['mid'][0], m['rid'][0] , str(m['objectClass'][0])[7:], str(m['host'][0]).split('.')[0],
|
||||||
|
m['ipHostNumber'][0] if m.get('ipHostNumber',[]) else '-', m['macAddress'][0],
|
||||||
|
m.blacklist_actif()[0] if m.blacklist_actif() else '-'] for m in machines],
|
||||||
|
titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse MAC', u'Limitation'],
|
||||||
|
largeur = [5, 5, 6, '*', 15, 17, 10],
|
||||||
|
alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c'])
|
||||||
|
|
||||||
|
def list_factures(factures):
|
||||||
|
return tableau([
|
||||||
|
[f['fid'][0], f['modePaiement'][0],
|
||||||
|
coul("OK", "vert") if f.get('recuPaiement', []) else coul("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],
|
||||||
|
titre = [u'fid', u'Mode de paiement', u'Payé', u'Articles', u"Total"],
|
||||||
|
largeur = [5, 16, 6, '*', 8],
|
||||||
|
alignement = ['d', 'g', 'c', 'g', 'd'])
|
||||||
|
|
||||||
|
def list_adherents(adherents):
|
||||||
|
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'),
|
||||||
|
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'],
|
||||||
|
largeur = [5, 35, 5, 1, 1, '*'],
|
||||||
|
alignement = ['d', 'c', 'c', 'c', 'c', 'g'])
|
||||||
|
|
||||||
def proprio(proprio, params):
|
def proprio(proprio, params):
|
||||||
params['o']=proprio
|
params['o']=proprio
|
||||||
etat_administratif=[]
|
etat_administratif=[]
|
||||||
|
@ -71,6 +104,11 @@ def proprio(proprio, params):
|
||||||
params['etat_administratif']=etat_administratif
|
params['etat_administratif']=etat_administratif
|
||||||
if proprio["chbre"][0].value not in ["????", "EXT"]:
|
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'] = coul("Cr@ns", "bleu") if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else coul("CROUS", "jaune")
|
||||||
|
|
||||||
|
if proprio.machines():
|
||||||
|
params['machines']=list_machines(proprio.machines())
|
||||||
|
if proprio.factures():
|
||||||
|
params['factures']=list_factures(proprio.factures())
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def club(club, params):
|
def club(club, params):
|
||||||
|
@ -86,8 +124,8 @@ def facture(facture, params):
|
||||||
return template().get_template("facture").render(params)
|
return template().get_template("facture").render(params)
|
||||||
|
|
||||||
def sprint(object, limit=5):
|
def sprint(object, limit=5):
|
||||||
params={'limit':limit}
|
|
||||||
from lc_ldap import objets
|
from lc_ldap import objets
|
||||||
|
params={'limit':limit}
|
||||||
if isinstance(object, objets.machine):
|
if isinstance(object, objets.machine):
|
||||||
return machine(object, params)
|
return machine(object, params)
|
||||||
elif isinstance(object, objets.adherent):
|
elif isinstance(object, objets.adherent):
|
||||||
|
@ -100,3 +138,24 @@ def sprint(object, limit=5):
|
||||||
return str(object)
|
return str(object)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def sprint_list(list):
|
||||||
|
from lc_ldap import objets
|
||||||
|
mlist={}
|
||||||
|
ret=[]
|
||||||
|
for o in list:
|
||||||
|
mlist[o.__class__] = mlist.get(o.__class__, []) + [o]
|
||||||
|
|
||||||
|
for classe, list in mlist.items():
|
||||||
|
if issubclass(classe, objets.machine):
|
||||||
|
ret.append(list_machines(list))
|
||||||
|
elif issubclass(classe, objets.adherent):
|
||||||
|
ret.append(list_adherents(list))
|
||||||
|
#elif issubclass(classe, objets.club):
|
||||||
|
# ret.append(list_clubs(list))
|
||||||
|
elif issubclass(classe, objets.facture):
|
||||||
|
ret.append(list_factures(list))
|
||||||
|
else:
|
||||||
|
ret.append("Listes d'objets de classe %s non affichage" % classe.__name__)
|
||||||
|
return '\n'.join(ret)
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,7 @@
|
||||||
{{"Brassage : "|coul('gras')}}{{brassage}}
|
{{"Brassage : "|coul('gras')}}{{brassage}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include 'blacklist' %}
|
{% include 'blacklist' %}
|
||||||
|
|
||||||
|
{{machines}}
|
||||||
|
|
||||||
|
{{factures}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue