diff --git a/printing/templates.py b/printing/templates.py index 4bab62c..a4c95e9 100644 --- a/printing/templates.py +++ b/printing/templates.py @@ -117,16 +117,17 @@ def machine(machine, params): return template().get_template("machine").render(params) -def list_machines(machines): +def list_machines(machines, width=None): 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']) + alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c'], + width=width) -def list_factures(factures): +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"), @@ -135,9 +136,10 @@ def list_factures(factures): ] 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']) + alignement = ['d', 'g', 'c', 'g', 'd'], + width=width) -def list_adherents(adherents): +def list_adherents(adherents, width=None): return tableau([ [a['aid'][0], u' '.join(unicode(i) for i in a['prenom'] + a['nom']), @@ -147,7 +149,20 @@ def list_adherents(adherents): ] 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']) + alignement = ['d', 'c', 'c', 'c', 'c', 'g'], + width=width) + +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'), + 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'], + largeur = [5, 35, 5, 1, '*'], + alignement = ['d', 'c', 'c', 'c', 'g'], + width=width) def proprio(proprio, params): params['o']=proprio @@ -196,27 +211,31 @@ def sprint(object, limit=5): return club(object, params) elif isinstance(object, objets.facture): return facture(object, params) + elif isinstance(object, attributs.blacklist): + return blacklist(object, params) else: return str(object) -def sprint_list(list): +def sprint_list(list, width=None): 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(): + classes = mlist.keys() + classes.sort() + for classe in classes: + list = mlist[classe] if issubclass(classe, objets.machine): - ret.append(list_machines(list)) + ret.append(list_machines(list, width)) elif issubclass(classe, objets.adherent): - ret.append(list_adherents(list)) - #elif issubclass(classe, objets.club): - # ret.append(list_clubs(list)) + ret.append(list_adherents(list, width)) + elif issubclass(classe, objets.club): + ret.append(list_clubs(list, width)) elif issubclass(classe, objets.facture): - ret.append(list_factures(list)) + ret.append(list_factures(list, width)) else: ret.append("Listes d'objets de classe %s non affichage" % classe.__name__) return '\n'.join(ret)