[attributs] toujours plus d'attributs, on va pe en venir à bout... X_x'
This commit is contained in:
parent
7f4f64f9af
commit
fe9a974e0a
1 changed files with 138 additions and 68 deletions
144
attributs.py
144
attributs.py
|
@ -133,18 +133,21 @@ class objectClass(Attr):
|
||||||
self.value = unicode(val)
|
self.value = unicode(val)
|
||||||
|
|
||||||
|
|
||||||
class aid(Attr):
|
class intAttr(Attr):
|
||||||
singlevalue = True
|
def parse_value(self, val, ldif):
|
||||||
optional = True
|
if int(val) <= 0:
|
||||||
legend = u"Identifiant de l'adhérent"
|
raise ValueError("Valeur entière invalide : %s" % val)
|
||||||
|
self.value = int(val)
|
||||||
def parse_value(self, aid, ldif):
|
|
||||||
self.value = int(aid)
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.value)
|
return unicode(self.value)
|
||||||
|
|
||||||
class uid(Attr):
|
class aid(intAttr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = u"Identifiant de l'adhérent"
|
||||||
|
|
||||||
|
class uid(inAttr):
|
||||||
singlevalue = True
|
singlevalue = True
|
||||||
option = False
|
option = False
|
||||||
legend = u"L'identifiant canonique de l'adhérent"
|
legend = u"L'identifiant canonique de l'adhérent"
|
||||||
|
@ -178,33 +181,23 @@ class tel(Attr):
|
||||||
raise ValueError("Numéro de téléphone invalide ('%s')" % val)
|
raise ValueError("Numéro de téléphone invalide ('%s')" % val)
|
||||||
|
|
||||||
|
|
||||||
class paiement(Attr):
|
class yearAttr(intAttr):
|
||||||
singlevalue = False
|
singlevalue = False
|
||||||
optional= True
|
optional= True
|
||||||
|
|
||||||
|
def parse_value(self, val, ldif):
|
||||||
|
if int(val) < 1998 or int(val) > config.ann_scol:
|
||||||
|
raise ValueError("Année invalide (%s)" % val)
|
||||||
|
self.value = int(val)
|
||||||
|
|
||||||
|
|
||||||
|
class paiement(intAttr):
|
||||||
legend = u"Paiement"
|
legend = u"Paiement"
|
||||||
|
|
||||||
def parse_value(self, val, ldif):
|
|
||||||
if int(val) < 1998 or int(val) > config.ann_scol:
|
|
||||||
raise ValueError("Année de cotisation invalide (%s)" % val)
|
|
||||||
self.value = int(val)
|
|
||||||
|
|
||||||
def __unicode__(self):
|
class carteEtudiant(intAttr):
|
||||||
return unicode(self.value)
|
|
||||||
|
|
||||||
|
|
||||||
class carteEtudiant(Attr):
|
|
||||||
singlevalue = False
|
|
||||||
optional = True
|
|
||||||
legend = u"Carte d'étudiant"
|
legend = u"Carte d'étudiant"
|
||||||
|
|
||||||
def parse_value(self, val, ldif):
|
|
||||||
if int(val) < 1998 or int(val) > config.ann_scol:
|
|
||||||
raise ValueError("Année de cotisation invalide (%s)" % val)
|
|
||||||
self.value = int(val)
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.value)
|
|
||||||
|
|
||||||
|
|
||||||
class mailAlias(Attr):
|
class mailAlias(Attr):
|
||||||
singlevalue = False
|
singlevalue = False
|
||||||
|
@ -343,7 +336,7 @@ class puissance(Attr):
|
||||||
optional = True
|
optional = True
|
||||||
legend = u"puissance d'émission pour les bornes wifi"
|
legend = u"puissance d'émission pour les bornes wifi"
|
||||||
|
|
||||||
class canal(Attr):
|
class canal(intAttr):
|
||||||
singlevalue = True
|
singlevalue = True
|
||||||
optional = True
|
optional = True
|
||||||
legend = u'Canal d\'émission de la borne'
|
legend = u'Canal d\'émission de la borne'
|
||||||
|
@ -354,6 +347,8 @@ class portAttr(Attr):
|
||||||
optional = True
|
optional = True
|
||||||
|
|
||||||
def parse_value(self, port, ldif):
|
def parse_value(self, port, ldif):
|
||||||
|
if int(port) <0 or int(port)> 65535:
|
||||||
|
raise ValueError("Port invalide: %s" % port)
|
||||||
self.value = int(port)
|
self.value = int(port)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
@ -381,17 +376,11 @@ class prise(Attr):
|
||||||
### Tu es une nounou, je te fais confiance
|
### Tu es une nounou, je te fais confiance
|
||||||
self.value = prise
|
self.value = prise
|
||||||
|
|
||||||
class cid(Attr):
|
class cid(intAttr):
|
||||||
singlevalue = True
|
singlevalue = True
|
||||||
optional = True
|
optional = True
|
||||||
legend = u"Identifiant du club"
|
legend = u"Identifiant du club"
|
||||||
|
|
||||||
def parse_value(self, cid, ldif):
|
|
||||||
self.value = int(cid)
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.value)
|
|
||||||
|
|
||||||
|
|
||||||
class responsable(Attr):
|
class responsable(Attr):
|
||||||
singlevalue = True
|
singlevalue = True
|
||||||
|
@ -426,6 +415,76 @@ class historique(Attr):
|
||||||
optional = True
|
optional = True
|
||||||
legend = u"Historique de l'objet"
|
legend = u"Historique de l'objet"
|
||||||
|
|
||||||
|
class info(Attr):
|
||||||
|
singlevalue = False
|
||||||
|
optional = True
|
||||||
|
legend = u"Quelques informations"
|
||||||
|
|
||||||
|
class homepageAlias(Attr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = u'Un alias pour la page personnelle'
|
||||||
|
|
||||||
|
class charteMA(Attr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend= "Signale si l'adhérent a signé la charte de membres actifs"
|
||||||
|
|
||||||
|
def parse_value(self, signed, ldif):
|
||||||
|
if signed.upper() not in ["TRUE", "FALSE"]:
|
||||||
|
raise ValueError("La charte MA est soit TRUE ou FALSE, pas %s" % signed)
|
||||||
|
self.value = signed.upper()
|
||||||
|
|
||||||
|
class homeDirectory(Attr):
|
||||||
|
singlevalue=True
|
||||||
|
optional = True
|
||||||
|
legend="Le chemin du home de l'adhérent"
|
||||||
|
|
||||||
|
def parse_value(self, home, ldif):
|
||||||
|
if home != '/home/' + ldif['uid'][0]:
|
||||||
|
raise ValueError("Le répertoire personnel n'est pas bon: %s (devrait être %s)" %
|
||||||
|
(home, '/home/'+ ldif['uid'][0]))
|
||||||
|
self.value = home
|
||||||
|
|
||||||
|
class loginShell(Attr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = "Le shell de l'adherent"
|
||||||
|
|
||||||
|
def parse_value(self, shell, ldif):
|
||||||
|
with open('/etc/shells') as f:
|
||||||
|
shells = f.readlines()
|
||||||
|
if (shell not in shells) or shell.startswith('#'):
|
||||||
|
raise ValueError("Shell %s invalide" % shell)
|
||||||
|
self.value = shell
|
||||||
|
|
||||||
|
class uidNumber(intAttr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = "L'uid du compte de l'adherent"
|
||||||
|
|
||||||
|
class gidNumber(intAttr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = "Le gid du compte de l'adhérent"
|
||||||
|
|
||||||
|
class gecos(Attr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = True
|
||||||
|
legend = "Le gecos"
|
||||||
|
|
||||||
|
def parse_value(self, gecos, ldif):
|
||||||
|
a, b, c, d = gecos.split(',')
|
||||||
|
self.value = gecos
|
||||||
|
|
||||||
|
class mail(Attr):
|
||||||
|
singlevalue = True
|
||||||
|
optional = False
|
||||||
|
legend = "Le mail de l'adhérent"
|
||||||
|
|
||||||
|
# XXX - to be implemented
|
||||||
|
#def parse_value(self, mail, ldif):
|
||||||
|
# pass
|
||||||
|
|
||||||
CRANS_ATTRIBUTES= {
|
CRANS_ATTRIBUTES= {
|
||||||
'objectClass' : objectClass,
|
'objectClass' : objectClass,
|
||||||
|
@ -458,6 +517,17 @@ CRANS_ATTRIBUTES= {
|
||||||
'cid' : cid,
|
'cid' : cid,
|
||||||
'responsable' : responsable,
|
'responsable' : responsable,
|
||||||
'blacklist' : blacklist,
|
'blacklist' : blacklist,
|
||||||
'historique' : historique
|
'historique' : historique,
|
||||||
|
'info': info,
|
||||||
|
'homepageAlias': homepageAlias,
|
||||||
|
'charteMA': charteMA,
|
||||||
|
'mail' : mail,
|
||||||
|
|
||||||
|
# {posix,shadow}Account
|
||||||
|
'homeDirectory': homeDirectory,
|
||||||
|
'loginShell': loginShell,
|
||||||
|
'uidNumber': uidNumber,
|
||||||
|
'gecos': gecos,
|
||||||
|
'gidNumber': gidNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue