diff --git a/printing/templates.py b/printing/templates.py index e869e85..1e49a4d 100644 --- a/printing/templates.py +++ b/printing/templates.py @@ -34,6 +34,7 @@ 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 if chbre=="????": return coul("Chambre invalide", "violet") return gestion.whos.prise_etat(chbre)[0] @@ -87,11 +88,15 @@ def const_of_mac(mac): return mac templateEnv=None -def template(): - global templateEnv +def template(dialog=False): + global templateEnv, coul, 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 + oldtableau = tableau + tableau = lambda *args,**kwargs: oldtableau(*args,dialog=dialog,**kwargs) + coul = lambda *args,**kwargs:oldcoul(*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 )