From 23ebf9de76f37a530cc45a2ebf801d5193ca1a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 4 Mar 2013 07:08:12 +0100 Subject: [PATCH] =?UTF-8?q?[attributs]=20Bug=20fixes=20sur=20les=20attribu?= =?UTF-8?q?ts=20concernant=20les=20bornes,=20et=20ajout=20d'un=20attribut?= =?UTF-8?q?=20manquant=20=C3=A0=20la=20lookup=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/attributs.py b/attributs.py index 729a9ee..c85d651 100644 --- a/attributs.py +++ b/attributs.py @@ -93,7 +93,7 @@ class Attr(object): can_modify = [nounou] - can_view = [nounou, apprenti, soi, parent, responsable] + can_view = [nounou, apprenti, soi, parent, respo] """Qui peut voir l'attribut. Par défaut, les Nounous et les Apprentis peuvent tout voir. Par transparence, et par utilité, on autorise par défaut l'adhérent à voir les données le concernant.""" @@ -200,12 +200,17 @@ class intAttr(Attr): class boolAttr(Attr): def parse_value(self, val, ldif): - if not isinstance(val, bool): - raise ValueError("Valeur pour attribut booléen invalide : %r" % val) - self.value = val + if val.lower() == u'true': + self.value = True + elif val.lower() == u'false': + self.value = False + elif isinstance(val, bool): + self.value = val + else: + raise ValueError("%r doit être un booléen !" % val) def __unicode__(self): - return unicode(self.value) + return unicode(self.value).upper() class aid(intAttr): singlevalue = True @@ -592,8 +597,11 @@ class positionBorne(Attr): optional = True def parse_value(self, val, ldif): - lat, lon = val.split(" ") - self.value = u"%f %f" % (float(lat), float(lon)) + if val == u'N/A N/A': + self.value = u"N/A°N N/A°E" + else: + lat, lon = val.split(" ") + self.value = u"%f°N %f°E" % (float(lat), float(lon)) class nvram(Attr): legend = u"Configuration speciale" @@ -930,6 +938,7 @@ CRANS_ATTRIBUTES= { 'tel' : tel, 'paiement' : paiement, 'controle': controle, + 'derniereConnexion' : derniereConnexion, 'carteEtudiant' : carteEtudiant, 'mailAlias' : mailAlias, 'canonicalAlias' : canonicalAlias,