[printing] Club, adherent, machines affichable de façon plus exhaustive
This commit is contained in:
parent
1b424e5afb
commit
702f941469
8 changed files with 124 additions and 45 deletions
|
@ -1,39 +1,79 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('/usr/scripts/')
|
sys.path.append('/usr/scripts/')
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
from gestion.affich_tools import coul
|
from gestion.affich_tools import coul
|
||||||
from lc_ldap import objets
|
from lc_ldap import objets
|
||||||
|
import time
|
||||||
|
|
||||||
|
import gestion.whos
|
||||||
|
import gestion.annuaires_pg
|
||||||
|
|
||||||
|
def prise_etat(chbre):
|
||||||
|
if chbre=="????":
|
||||||
|
return coul("Chambre invalide", "violet")
|
||||||
|
return gestion.whos.prise_etat(chbre)[0]
|
||||||
|
|
||||||
|
def timeformat(t, format):
|
||||||
|
return time.strftime(format, time.localtime(t))
|
||||||
|
|
||||||
|
def blacklist(l):
|
||||||
|
bl=[]
|
||||||
|
for b in l:
|
||||||
|
b=b.value
|
||||||
|
debut=time.strftime("%d/%m/%Y %H:%M", time.localtime(b['debut']))
|
||||||
|
fin=time.strftime("%d/%m/%Y %H:%M", time.localtime(b['fin']))
|
||||||
|
couleur='rouge' if b['actif'] else None
|
||||||
|
bl.append(coul("du %s au %s : %s [%s]" % (debut, fin, b['type'], b['comm']), couleur))
|
||||||
|
return bl
|
||||||
|
|
||||||
|
def split(str, *arg):
|
||||||
|
return str.split(*arg)
|
||||||
|
|
||||||
template_path = '/usr/scripts/lc_ldap/printing/templates/'
|
template_path = '/usr/scripts/lc_ldap/printing/templates/'
|
||||||
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
|
templateLoader = jinja2.FileSystemLoader( searchpath=["/", template_path] )
|
||||||
templateEnv = jinja2.Environment( loader=templateLoader )
|
templateEnv = jinja2.Environment( loader=templateLoader, trim_blocks=True )
|
||||||
templateEnv.filters['coul'] = coul
|
templateEnv.filters['coul'] = coul
|
||||||
|
templateEnv.filters['blacklist'] = blacklist
|
||||||
|
templateEnv.filters['prise_etat'] = prise_etat
|
||||||
|
templateEnv.filters['timeformat'] = timeformat
|
||||||
|
templateEnv.filters['split'] = split
|
||||||
|
|
||||||
def machine(machine, limit):
|
def machine(machine, params):
|
||||||
params={}
|
params['o']=machine
|
||||||
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)
|
return templateEnv.get_template("machine").render(params)
|
||||||
|
|
||||||
def adherent(adherent, limit):
|
def proprio(proprio, params):
|
||||||
params={}
|
params['o']=proprio
|
||||||
params.update(adherent.attrs)
|
etat_administratif=[]
|
||||||
params['etat']=adherent.paiement_ok()
|
if proprio.paiement_ok() and proprio.carte_ok():
|
||||||
if limit:
|
etat_administratif.append(coul(u"à jour", "vert"))
|
||||||
for attr in ['historique', 'blacklist']:
|
if not proprio.carte_ok():
|
||||||
if params.get(attr, []) and len(params[attr])>limit:
|
etat_administratif.append(coul(u"manque carte d'étudiant", "violet"))
|
||||||
params[attr]=params[attr][0:limit]
|
if not proprio.paiement_ok():
|
||||||
|
etat_administratif.append(coul(u"cotisation non réglée", "violet"))
|
||||||
|
params['etat_administratif']=etat_administratif
|
||||||
|
if proprio["chbre"][0].value not in ["????", "EXT"]:
|
||||||
|
params['brassage'] = coul("Cr@ns", "bleu") if gestion.annuaires_pg.is_crans(proprio["chbre"][0].value[0], proprio["chbre"][0].value[1:]) else coul("CROUS", "jaune")
|
||||||
|
return params
|
||||||
|
|
||||||
|
def club(club, params):
|
||||||
|
params=proprio(club, params)
|
||||||
|
return templateEnv.get_template("club").render(params)
|
||||||
|
|
||||||
|
def adherent(adherent, params):
|
||||||
|
params=proprio(adherent, params)
|
||||||
return templateEnv.get_template("adherent").render(params)
|
return templateEnv.get_template("adherent").render(params)
|
||||||
|
|
||||||
def sprint(object, limit=10):
|
def sprint(object, limit=5):
|
||||||
|
params={'limit':limit}
|
||||||
if isinstance(object, objets.machine):
|
if isinstance(object, objets.machine):
|
||||||
return machine(object, limit)
|
return machine(object, params)
|
||||||
elif isinstance(object, objets.adherent):
|
elif isinstance(object, objets.adherent):
|
||||||
return adherent(object, limit)
|
return adherent(object, params)
|
||||||
|
elif isinstance(object, objets.club):
|
||||||
|
return club(object, params)
|
||||||
else:
|
else:
|
||||||
return str(object)
|
return str(object)
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
{{["aid=",aid.0]|join|coul('bleu')}} {{"Nom : "|coul('gras')}}{{prenom|join(' ')}} {{nom|join(' ')}}
|
{% extends "proprio" %}
|
||||||
{%if uid %}{{"Login : "|coul('gras')}}{{uid.0}} {{"Alias : "|coul('gras')}}{{mailAlias|join(', ')}}
|
{% block id %}
|
||||||
{{"Droits sur les serveurs : "|coul('gras')}}{{droits|join(', ')}}
|
{{["aid=",o.aid.0]|join|coul('bleu')}} {{"Nom : "|coul('gras')}}{{o.prenom|join(' ')}} {{o.nom|join(' ')}}
|
||||||
{{"Dernière connexion : "|coul('gras')}}{{derniereConnexion|join}}
|
{% endblock%}
|
||||||
{{"Solde : "|coul('gras')}}{{solde.0}}
|
{% block proprio %}
|
||||||
{% endif %}{{"Date d'inscription : "|coul('gras')}}
|
{{"Numéro de téléphone : "|coul('gras')}}{{o.tel|join(', ')}}
|
||||||
{{"État administratif : "|coul('gras')}}{{etat}}
|
{{"Chambre : "|coul('gras')}}{{o.chbre.0}} ({{o.chbre.0|string|prise_etat}})
|
||||||
{{"Numéro de téléphone : "|coul('gras')}}{{tel|join(', ')}}
|
{{"Études : "|coul('gras')}}{{o.etudes|join(' ')}}
|
||||||
{{"Chambre : "|coul('gras')}}{{chbre|join(', ')}}
|
{{"Cotisation payée pour les années : "|coul('gras')}}{{o.paiement|join(' ')}} {% if 'p' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||||
{{"Brassage : "|coul('gras')}}
|
{{"Carte d'étudiant fournie pour les années : "|coul('gras')}}{{o.carteEtudiant|join(' ')}} {% if 'c' in o.controle.0.value %}{{"(OK)"|coul('vert')}}{% endif %}
|
||||||
{{"Études : "|coul('gras')}}{{etudes|join(' ')}}
|
{% endblock%}
|
||||||
{{"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 ')}}
|
|
||||||
|
|
4
printing/templates/blacklist
Normal file
4
printing/templates/blacklist
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{% if o.__getitem__('blacklist') %}
|
||||||
|
{{"Blackliste : "|coul('gras')}}{{o.__getitem__('blacklist')[-limit:]|reverse|blacklist|join('\n ')}}
|
||||||
|
{% endif %}
|
||||||
|
{% include 'object' %}
|
11
printing/templates/club
Normal file
11
printing/templates/club
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "proprio" %}
|
||||||
|
{% block id %}
|
||||||
|
{{["cid=",o.cid.0]|join|coul('bleu')}} {{"Nom : "|coul('gras')}}{{o.nom|join(' ')}}
|
||||||
|
{% endblock%}
|
||||||
|
{% block proprio %}
|
||||||
|
{{"Responsable : "|coul('gras')}}{{o.responsable.0.value.prenom|join(' ')}} {{o.responsable.0.value.nom|join(' ')}} ({{o.responsable.0.value.aid|join(' ')}})
|
||||||
|
{{"Imprimeurs : "|coul('gras')}}{% for i in o.imprimeurClub %}{{i.value.prenom|join(' ')}} {{i.value.nom|join(' ')}} ({{i.value.aid|join(' ')}}) {% endfor%}
|
||||||
|
|
||||||
|
{{"Local : "|coul('gras')}}{{o.chbre.0}} ({{o.chbre.0|string|prise_etat}})
|
||||||
|
{{"Charte signée pour les années scolaires : "|coul('gras')}}{{o.paiement|join(' ')}}
|
||||||
|
{% endblock%}
|
12
printing/templates/compte_crans
Normal file
12
printing/templates/compte_crans
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{{"Login : "|coul('gras')}}{{o.uid.0}} {{"Alias : "|coul('gras')}}{{o.mailAlias|join(', ')}}
|
||||||
|
{% if o.droits %}
|
||||||
|
{{"Droits sur les serveurs : "|coul('gras')}}{{o.droits|join(', ')}}
|
||||||
|
{% endif %}
|
||||||
|
{{"Dernière connexion : "|coul('gras')}}{%if derniereConnexion %}
|
||||||
|
{{o.derniereConnexion.0|timeformat}}
|
||||||
|
{% else %}
|
||||||
|
{{"Jamais"|coul('rouge')}}
|
||||||
|
{% endif %}
|
||||||
|
{% if o.solde %}
|
||||||
|
{{"Solde : "|coul('gras')}}{{o.solde.0}}€
|
||||||
|
{% endif %}
|
|
@ -1,8 +1,9 @@
|
||||||
{{["mid=",mid.0]|join|coul('bleu')}} {{[objectClass.0, " : "]|join|coul('gras')}}{{host.0}} {{["rid=",rid.0]|join|coul('bleu')}}
|
{{["mid=",o.mid.0]|join|coul('bleu')}} {{[o.objectClass.0, " : "]|join|coul('gras')}}{{o.host.0}} {{["rid=",o.rid.0]|join|coul('bleu')}}
|
||||||
{{"Alias : "|coul('gras')}}{{alias|join(', ')}}
|
{% if o.alias %}
|
||||||
{{"MAC : "|coul('gras')}}{{macAddress|join(', ')}}
|
{{"Alias : "|coul('gras')}}{{o.alias|join(', ')}}
|
||||||
{{"IPv4 : "|coul('gras')}}{{ipHostNumber|join(', ')}}
|
{% endif %}
|
||||||
{{"IPv6 : "|coul('gras')}}{{ip6HostNumber|join(', ')}}
|
{{"MAC : "|coul('gras')}}{{o.macAddress|join(', ')}}
|
||||||
{{"Propriétaire : "|coul('gras')}}{{proprio.prenom|join(', ')}} {{proprio.nom|join(', ')}} (aid={{proprio.aid|join(', ')}})
|
{{"IPv4 : "|coul('gras')}}{{o.ipHostNumber|join(', ')}}
|
||||||
{{"Blackliste : "|coul('gras')}}{{blacklist|join('\n ')}}
|
{{"IPv6 : "|coul('gras')}}{{o.ip6HostNumber|join(', ')}}
|
||||||
{{"Historique : "|coul('gras')}}{{historique|join('\n ')}}
|
{{"Propriétaire : "|coul('gras')}}{{o.proprio().prenom|join(', ')}} {{o.proprio().nom|join(', ')}} (aid={{o.proprio().aid|join(', ')}})
|
||||||
|
{% include 'blacklist' %}
|
||||||
|
|
6
printing/templates/object
Normal file
6
printing/templates/object
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{% if o.info %}
|
||||||
|
{{"Remarque : "|coul('gras')}}{{o.info|reverse|join('\n ')}}
|
||||||
|
{% endif %}
|
||||||
|
{% if o.historique %}
|
||||||
|
{{"Historique : "|coul('gras')}}{{o.historique[-limit:]|reverse|join('\n ')}}
|
||||||
|
{% endif %}
|
11
printing/templates/proprio
Normal file
11
printing/templates/proprio
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% block id %}{% endblock %}
|
||||||
|
{{"Date d'inscription : "|coul('gras')}}{{o.historique.0|string|split(',',1)|first}}
|
||||||
|
{{"État administratif : "|coul('gras')}}{{etat_administratif|join(' et ')}}
|
||||||
|
{%if o.uid %}
|
||||||
|
{% include 'compte_crans' %}
|
||||||
|
{% endif %}
|
||||||
|
{% block proprio %}{% endblock %}
|
||||||
|
{% if brassage %}
|
||||||
|
{{"Brassage : "|coul('gras')}}{{brassage}}
|
||||||
|
{% endif %}
|
||||||
|
{% include 'blacklist' %}
|
Loading…
Add table
Add a link
Reference in a new issue