[printing] Fonctions d'affichage pour les objets lc_ldap
pour le moment il n'y a qu'un support partiel pour les machines et les adherents
This commit is contained in:
parent
ad58564193
commit
1b424e5afb
4 changed files with 65 additions and 0 deletions
1
printing/__init__.py
Normal file
1
printing/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from templates import *
|
39
printing/templates.py
Normal file
39
printing/templates.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import sys
|
||||
sys.path.append('/usr/scripts/')
|
||||
import jinja2
|
||||
|
||||
from gestion.affich_tools import coul
|
||||
from lc_ldap import objets
|
||||
|
||||
template_path = '/usr/scripts/lc_ldap/printing/templates/'
|
||||
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
|
||||
templateEnv = jinja2.Environment( loader=templateLoader )
|
||||
templateEnv.filters['coul'] = coul
|
||||
|
||||
def machine(machine, limit):
|
||||
params={}
|
||||
params.update(machine.attrs)
|
||||
params['proprio']=machine.proprio().attrs
|
||||
if limit:
|
||||
for attr in ['historique', 'blacklist']:
|
||||
if params.get(attr, []) and len(params[attr])>limit:
|
||||
params[attr]=params[attr][0:limit]
|
||||
return templateEnv.get_template("machine").render(params)
|
||||
|
||||
def adherent(adherent, limit):
|
||||
params={}
|
||||
params.update(adherent.attrs)
|
||||
params['etat']=adherent.paiement_ok()
|
||||
if limit:
|
||||
for attr in ['historique', 'blacklist']:
|
||||
if params.get(attr, []) and len(params[attr])>limit:
|
||||
params[attr]=params[attr][0:limit]
|
||||
return templateEnv.get_template("adherent").render(params)
|
||||
|
||||
def sprint(object, limit=10):
|
||||
if isinstance(object, objets.machine):
|
||||
return machine(object, limit)
|
||||
elif isinstance(object, objets.adherent):
|
||||
return adherent(object, limit)
|
||||
else:
|
||||
return str(object)
|
17
printing/templates/adherent
Normal file
17
printing/templates/adherent
Normal file
|
@ -0,0 +1,17 @@
|
|||
{{["aid=",aid.0]|join|coul('bleu')}} {{"Nom : "|coul('gras')}}{{prenom|join(' ')}} {{nom|join(' ')}}
|
||||
{%if uid %}{{"Login : "|coul('gras')}}{{uid.0}} {{"Alias : "|coul('gras')}}{{mailAlias|join(', ')}}
|
||||
{{"Droits sur les serveurs : "|coul('gras')}}{{droits|join(', ')}}
|
||||
{{"Dernière connexion : "|coul('gras')}}{{derniereConnexion|join}}
|
||||
{{"Solde : "|coul('gras')}}{{solde.0}}
|
||||
{% endif %}{{"Date d'inscription : "|coul('gras')}}
|
||||
{{"État administratif : "|coul('gras')}}{{etat}}
|
||||
{{"Numéro de téléphone : "|coul('gras')}}{{tel|join(', ')}}
|
||||
{{"Chambre : "|coul('gras')}}{{chbre|join(', ')}}
|
||||
{{"Brassage : "|coul('gras')}}
|
||||
{{"Études : "|coul('gras')}}{{etudes|join(' ')}}
|
||||
{{"Cotisation payée pour les années :"|coul('gras')}}
|
||||
{{paiement|join(' ')}}
|
||||
{{"Carte d'étudiant fournie pour les années :"|coul('gras')}}
|
||||
{{carteEtudiant|join(' ')}}
|
||||
{{"Blackliste : "|coul('gras')}}{{blacklist|join('\n ')}}
|
||||
{{"Historique : "|coul('gras')}}{{historique|join('\n ')}}
|
8
printing/templates/machine
Normal file
8
printing/templates/machine
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{["mid=",mid.0]|join|coul('bleu')}} {{[objectClass.0, " : "]|join|coul('gras')}}{{host.0}} {{["rid=",rid.0]|join|coul('bleu')}}
|
||||
{{"Alias : "|coul('gras')}}{{alias|join(', ')}}
|
||||
{{"MAC : "|coul('gras')}}{{macAddress|join(', ')}}
|
||||
{{"IPv4 : "|coul('gras')}}{{ipHostNumber|join(', ')}}
|
||||
{{"IPv6 : "|coul('gras')}}{{ip6HostNumber|join(', ')}}
|
||||
{{"Propriétaire : "|coul('gras')}}{{proprio.prenom|join(', ')}} {{proprio.nom|join(', ')}} (aid={{proprio.aid|join(', ')}})
|
||||
{{"Blackliste : "|coul('gras')}}{{blacklist|join('\n ')}}
|
||||
{{"Historique : "|coul('gras')}}{{historique|join('\n ')}}
|
Loading…
Add table
Add a link
Reference in a new issue