diff --git a/attributs.py b/attributs.py index 4a0b238..64e1369 100644 --- a/attributs.py +++ b/attributs.py @@ -198,6 +198,15 @@ class intAttr(Attr): def __unicode__(self): return unicode(self.value) +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 + + def __unicode__(self): + return unicode(self.value) + class aid(intAttr): singlevalue = True optional = True @@ -286,6 +295,10 @@ class carteEtudiant(yearAttr): category = 'perso' can_modify = [cableur, nounou, tresorier] +class derniereConnexion(intAttr): + legend = u"Dernière connexion" + can_modify = [] + class mail(Attr): singlevalue = True optional = False @@ -334,6 +347,17 @@ class mailAlias(mail): raise ValueError("Alias mail invalide (%r)" % val) self.value = val +class mailInvalide(boolAttr): + optional = True + legend = u"Mail invalide" + can_modify = [bureau, nounou] + +class contourneGreylist(boolAttr): + optionnal = True + legend = u"Contourner la greylist" + category = 'mail' + can_modify = [soi] + class etudes(Attr): singlevalue = False optional = False @@ -553,6 +577,32 @@ class canal(intAttr): category = 'wifi' can_modify = [nounou] +class hotspot(boolAttr): + singlevalue = True + optional = True + legend = u'Hotspot' + category = 'wifi' + can_modify = [nounou] + +class positionBorne(Attr): + legend = u"Position de la borne" + category = "wifi" + can_modify = [nounou] + singlevalue = True + optional = True + + def parse_value(self, val, ldif): + lat, lon = val.split(" ") + self.value = u"%f %f" % (float(lat), float(lon)) + +class nvram(Attr): + legend u"Configuration speciale" + optional = True + can_modify = [nounou] + + def parse_value(self, val, ldif): + pass + class portAttr(Attr): singlevalue = False optional = True @@ -604,6 +654,13 @@ class portUDPin(portAttr): class exempt(Attr): legend = u"Exemption vers une IP" +class nombrePrise(intAttr): + legend = u"Nombre de prises ethernet de la machine" + singlevalue = True + optional = True + categoriy = 'base_tech' + can_modify = [nounou] + class prise(Attr): singlevalue = True optional = True @@ -630,7 +687,7 @@ class responsable(Attr): optional = True legend = u"Responsable du club" category = 'perso' - can_modify = [nounou] + can_modify = [cableur, nounou] def get_respo(self): if self.value == None: @@ -644,6 +701,21 @@ class responsable(Attr): def __unicode__(self): return self.__resp +class imprimeurClub(Attr): + optional = True + legend = u"Imprimeur du club" + category = "perso" + can_modify = [cableur, nounou] + + def parse_value(self, val, ldif): + res = self.conn.search('aid=%s' % int(val)) + if len(res) != 1: + raise ValueError("L'adhérent aid=%r n'existe plus." % val) + self.value = res[0] + + def __unicode__(self): + return unicode(self.value['aid'][0]) + class blacklist(Attr): singlevalue = False optional = True @@ -821,6 +893,20 @@ class controle(Attr): else: self.value = ctrl +class fid(intAttr): + legend = u"Id de facture" + category = 'factures' + optional = False + singlevalue = True + +class modePaiement(Attr): + legend = u"Mode de paiement" + category = 'factures' + optional = False + singlevalue = True + +class recuPaiement(Attr): + pass ### Les classes ADHERENT_ATTRS = [ nom, prenom, tel, chbre, postalAddress, mail, uid, diff --git a/lc_ldap.py b/lc_ldap.py index 279b350..1e7e5ce 100644 --- a/lc_ldap.py +++ b/lc_ldap.py @@ -588,7 +588,7 @@ class CransLdapObject(object): def has_key(self, attr): """Est-ce que notre objet a l'attribut en question ?""" - return attr in [attrib.__class__.__name__ for attrib in self.attributs] + return attr in [attrib.__class__.__name__ for attrib in self.attribs] def __setitem__(self, attr, values): if self.mode not in ['w', 'rw']: