diff --git a/attributs.py b/attributs.py index ddb56ae..d3d901b 100644 --- a/attributs.py +++ b/attributs.py @@ -640,9 +640,6 @@ class generalizedTimeFormat(Attr): __slots__ = ("_stamp", "_datetime",) default = "19700101000000Z" - def __unicode__(self): - return self._datetime.strftime("%d/%m/%Y %H:%M:%S") - def __float__(self): return self._stamp diff --git a/crans_utils.py b/crans_utils.py index a7026b1..0e5357d 100644 --- a/crans_utils.py +++ b/crans_utils.py @@ -349,6 +349,12 @@ def localized_datetime(date=None, tz=None): """Builds a datetime object based on a date string formatted as %Y%m%d%H%M%S, and a tz timezone looking like +0200""" + if tz is None: + if "+" in date or '-' in date or 'Z' in date: + if date.endswith("Z"): + date = date[:-1] + "+0000" + date, tz = date[:-5], date[-5:] + _notz = (tz is None) # Shit may happen diff --git a/printing/templates/templates.py b/printing/templates/templates.py index 7603da5..4686f80 100644 --- a/printing/templates/templates.py +++ b/printing/templates/templates.py @@ -16,6 +16,7 @@ import gestion.annuaires_pg import gestion.hptools2 as hptools2 import lc_ldap.attributs as attributs +import lc_ldap.crans_utils as crans_utils def try_import(lib): """ @@ -201,16 +202,21 @@ def list_factures(factures, width=None): data = [] for facture in factures: controle = facture.get('controle', [""])[0] - if controle == "TRUE": + if controle == u"TRUE": controle = style(u"Validée", "vert") - elif controle == "FALSE": + elif controle == u"FALSE": controle = style(u"Invalide", "rouge") else: controle = u"N/A" + if facture.get('recuPaiement', []): + _dtime = crans_utils.datetime_from_generalized_time_format(unicode(facture.get('recuPaiement', [attributs.recuPaiement.default])[0])) + _recu = _dtime.strftime("%d/%m/%Y %H:%M:%S") + else: + _recu = False data.append([ facture['fid'][0], facture['modePaiement'][0], - style(facture.get('recuPaiement', [])[0], "vert") if facture.get('recuPaiement', []) else style("NON", "rouge"), + style(_recu, 'vert') if _recu else style(u"NON", 'rouge'), controle, ' '.join(attr['code'] for attr in facture.get('article',[])), u"%s €" % sum([float(a['pu'])*int(a['nombre']) for a in facture.get('article',[])])