[printing] Possibilité d'afficher des blacklists seule

This commit is contained in:
Valentin Samir 2014-03-15 22:42:21 +01:00
parent 937aefb3ec
commit db6cf98661
5 changed files with 27 additions and 10 deletions

View file

@ -43,7 +43,7 @@ def prise_etat(chbre):
def timeformat(t, format): def timeformat(t, format):
return time.strftime(format, time.localtime(t)) return time.strftime(format, time.localtime(t))
def blacklist(l): def blacklists(l):
bl=[] bl=[]
for b in l: for b in l:
debut=b['debut'] if b['debut'] == '-' else time.strftime("%d/%m/%Y %H:%M", time.localtime(b['debut'])) 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 = jinja2.Environment( loader=templateLoader, trim_blocks=True )
templateEnv.add_extension('jinja2.ext.do') templateEnv.add_extension('jinja2.ext.do')
templateEnv.filters['coul'] = coul templateEnv.filters['coul'] = coul
templateEnv.filters['blacklist'] = blacklist templateEnv.filters['blacklists'] = blacklists
templateEnv.filters['prise_etat'] = prise_etat templateEnv.filters['prise_etat'] = prise_etat
templateEnv.filters['timeformat'] = timeformat templateEnv.filters['timeformat'] = timeformat
templateEnv.filters['split'] = split templateEnv.filters['split'] = split
@ -200,9 +200,13 @@ def facture(facture, params):
params['o']=facture params['o']=facture
return template().get_template("facture").render(params) return template().get_template("facture").render(params)
def sprint(object, limit=5): def blacklist(blacklist, params):
from lc_ldap import objets params['o']=blacklist
params={'limit':limit} 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): if isinstance(object, objets.machine):
return machine(object, params) return machine(object, params)
elif isinstance(object, objets.adherent): elif isinstance(object, objets.adherent):

View file

@ -1,4 +1,13 @@
{% if o.get('blacklist', []) %} {{"Blackliste : "|coul('gras')}}{{o.type|coul('rouge')}}
{{"Blackliste : "|coul('gras')}}{{o.get('blacklist', [])[-limit:]|reverse|blacklist|join('\n ')}} {{"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 %} {% endif %}
{% include 'object' %}

View file

@ -0,0 +1,4 @@
{% if o.get('blacklist', []) %}
{{"Blackliste : "|coul('gras')}}{{o.get('blacklist', [])[-limit:]|reverse|blacklists|join('\n ')}}
{% endif %}
{% include 'object' %}

View file

@ -16,4 +16,4 @@
{% elif o.proprio().cid %} {% elif o.proprio().cid %}
{{"Propriétaire : "|coul('gras')}}{{o.proprio().nom|join(', ')}} (cid={{o.proprio().cid|join(', ')}}) {{"Propriétaire : "|coul('gras')}}{{o.proprio().nom|join(', ')}} (cid={{o.proprio().cid|join(', ')}})
{% endif %} {% endif %}
{% include 'blacklist' %} {% include 'blacklists' %}

View file

@ -8,7 +8,7 @@
{% if brassage %} {% if brassage %}
{{"Brassage : "|coul('gras')}}{{brassage}} {{"Brassage : "|coul('gras')}}{{brassage}}
{% endif %} {% endif %}
{% include 'blacklist' %} {% include 'blacklists' %}
{{machines}} {{machines}}