From db6cf9866105d5518d8b743335800de73df3fec8 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 15 Mar 2014 22:42:21 +0100 Subject: [PATCH] =?UTF-8?q?[printing]=20Possibilit=C3=A9=20d'afficher=20de?= =?UTF-8?q?s=20blacklists=20seule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- printing/templates.py | 14 +++++++++----- printing/templates/blacklist | 15 ++++++++++++--- printing/templates/blacklists | 4 ++++ printing/templates/machine | 2 +- printing/templates/proprio | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 printing/templates/blacklists diff --git a/printing/templates.py b/printing/templates.py index a4c95e9..9c69018 100644 --- a/printing/templates.py +++ b/printing/templates.py @@ -43,7 +43,7 @@ def prise_etat(chbre): def timeformat(t, format): return time.strftime(format, time.localtime(t)) -def blacklist(l): +def blacklists(l): bl=[] for b in l: debut=b['debut'] if b['debut'] == '-' else time.strftime("%d/%m/%Y %H:%M", time.localtime(b['debut'])) @@ -103,7 +103,7 @@ def template(dialog=False): templateEnv = jinja2.Environment( loader=templateLoader, trim_blocks=True ) templateEnv.add_extension('jinja2.ext.do') templateEnv.filters['coul'] = coul - templateEnv.filters['blacklist'] = blacklist + templateEnv.filters['blacklists'] = blacklists templateEnv.filters['prise_etat'] = prise_etat templateEnv.filters['timeformat'] = timeformat templateEnv.filters['split'] = split @@ -200,9 +200,13 @@ def facture(facture, params): params['o']=facture return template().get_template("facture").render(params) -def sprint(object, limit=5): - from lc_ldap import objets - params={'limit':limit} +def blacklist(blacklist, params): + params['o']=blacklist + return template().get_template("blacklist").render(params) + +def sprint(object, limit=5, **params): + from lc_ldap import objets, attributs + params.update({'limit':limit}) if isinstance(object, objets.machine): return machine(object, params) elif isinstance(object, objets.adherent): diff --git a/printing/templates/blacklist b/printing/templates/blacklist index 455b0a4..c5d7ddc 100644 --- a/printing/templates/blacklist +++ b/printing/templates/blacklist @@ -1,4 +1,13 @@ -{% if o.get('blacklist', []) %} -{{"Blackliste : "|coul('gras')}}{{o.get('blacklist', [])[-limit:]|reverse|blacklist|join('\n ')}} +{{"Blackliste : "|coul('gras')}}{{o.type|coul('rouge')}} +{{"Commentaire : "|coul('gras')}}{{o.comm}} +{{"Date de début : "|coul('gras')}}{{o.debut|timeformat('%d/%m/%Y %H:%M:%S')}} +{{"Date de fin : "|coul('gras')}}{% if o.fin != '-' %} +{{o.fin|timeformat('%d/%m/%Y %H:%M:%S')}} +{% else %} +{{"sans fin"|coul('rouge')}} +{% endif %} +{{"État : "|coul('gras')}}{% if o.actif %} +{{"ACTIVE"|coul('rouge')}} +{% else %} +{{"INACTIVE"|coul('vert')}} {% endif %} -{% include 'object' %} diff --git a/printing/templates/blacklists b/printing/templates/blacklists new file mode 100644 index 0000000..cac9c73 --- /dev/null +++ b/printing/templates/blacklists @@ -0,0 +1,4 @@ +{% if o.get('blacklist', []) %} +{{"Blackliste : "|coul('gras')}}{{o.get('blacklist', [])[-limit:]|reverse|blacklists|join('\n ')}} +{% endif %} +{% include 'object' %} diff --git a/printing/templates/machine b/printing/templates/machine index b8628f0..94429eb 100644 --- a/printing/templates/machine +++ b/printing/templates/machine @@ -16,4 +16,4 @@ {% elif o.proprio().cid %} {{"Propriétaire : "|coul('gras')}}{{o.proprio().nom|join(', ')}} (cid={{o.proprio().cid|join(', ')}}) {% endif %} -{% include 'blacklist' %} +{% include 'blacklists' %} diff --git a/printing/templates/proprio b/printing/templates/proprio index c552ad2..37534a6 100644 --- a/printing/templates/proprio +++ b/printing/templates/proprio @@ -8,7 +8,7 @@ {% if brassage %} {{"Brassage : "|coul('gras')}}{{brassage}} {% endif %} -{% include 'blacklist' %} +{% include 'blacklists' %} {{machines}}