From a4042c9c3b0a8b1ab0b7bf2ba736faafaa52cf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sat, 14 Feb 2015 14:35:23 +0100 Subject: [PATCH] Une fonction _id sur les objets pour rendre un peu plus facile leur gestion (bordel) --- objets.py | 12 ++++++++++++ printing/templates/facture | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/objets.py b/objets.py index ed37bca..f3a7bd6 100644 --- a/objets.py +++ b/objets.py @@ -205,6 +205,18 @@ class CransLdapObject(object): nvals = [nldif[attr][vals.index(v)] for v in vals ] raise EnvironmentError("λv. str(Attr(v)) n'est peut-être pas une projection (ie non idempotente):", attr, nvals, vals) + def _id(self): + """Retourne l'id de l'objet courant""" + if isinstance(self, adherent): + return self['aid'] + elif isinstance(self, machine): + return self['mid'] + elif isinstance(self, club): + return self['cid'] + elif isinstance(self, facture): + return self['fid'] + else: + return [self.dn] def _out_of_context(self, *args, **kwargs): raise EnvironmentError("Hors du context, impossible de faire des écritures") diff --git a/printing/templates/facture b/printing/templates/facture index d5dc21d..7aa46db 100644 --- a/printing/templates/facture +++ b/printing/templates/facture @@ -1,4 +1,4 @@ -{{["fid=",o.fid.0]|join|coul('bleu')}} {{"À : "|coul('gras')}}{{o.proprio().prenom|join(' ')}} {{o.proprio().nom|join(' ')}} ({{o.proprio().aid.0}}) +{{["fid=",o._id().0]|join|coul('bleu')}} {{"À : "|coul('gras')}}{{o.proprio().prenom|join(' ')}} {{o.proprio().nom|join(' ')}} ({{o.proprio()._id().0}}) {% if o.article %} {{"Article : "|coul('gras')}} Prix N° Total Commentaire {% set total = [] %}{% for a in o.article %}