Passage aux adhésions glissantes (partie 2/2, lc_ldap)
This commit is contained in:
parent
6880051943
commit
7f1ffbeed5
7 changed files with 180 additions and 30 deletions
79
attributs.py
79
attributs.py
|
@ -48,6 +48,7 @@ import random
|
|||
import string
|
||||
from unicodedata import normalize
|
||||
from crans_utils import format_tel, format_mac, mailexist, validate_name, ip4_of_rid, ip6_of_mac, fetch_cert_info
|
||||
from crans_utils import toGeneralizedTimeFormat, fromGeneralizedTimeFormat, extractTz
|
||||
import itertools
|
||||
|
||||
sys.path.append("/usr/scripts")
|
||||
|
@ -557,12 +558,86 @@ class derniereConnexion(intAttr):
|
|||
can_modify = [nounou, cableur, soi] # il faut bien pouvoir le modifier pour le mettre à jour
|
||||
ldap_name = "derniereConnexion"
|
||||
|
||||
class generalizedTimeFormat(Attr):
|
||||
"""Classe définissant un ensemble de données pour manipuler
|
||||
une donnée de temps suivant la RFC 4517
|
||||
|
||||
"""
|
||||
default = "19700101000000Z"
|
||||
|
||||
def __float__(self):
|
||||
return self._stamp
|
||||
|
||||
def __int__(self):
|
||||
return int(self._stamp)
|
||||
|
||||
def __eq__(self, othertime):
|
||||
if isinstance(self, othertime):
|
||||
return self._stamp == othertime._stamp
|
||||
else:
|
||||
resource = generalizedTimeFormat(othertime, conn=None, Parent=None)
|
||||
return self._stamp == resource._stamp
|
||||
|
||||
def __neq__(self, othertime):
|
||||
return not (self == othertime)
|
||||
|
||||
def __lt__(self, othertime):
|
||||
if isinstance(othertime, generalizedTimeFormat):
|
||||
return self._stamp < othertime._stamp
|
||||
else:
|
||||
resource = generalizedTimeFormat(othertime, conn=None, Parent=None)
|
||||
return self._stamp < resource._stamp
|
||||
|
||||
def __gt__(self, othertime):
|
||||
return not (self < othertime) and not (self == othertime)
|
||||
|
||||
def parse_value(self, gtf):
|
||||
if isinstance(gtf, str) or isinstance(gtf, unicode):
|
||||
if not ('Z' in gtf or '+' in gtf or '-' in gtf):
|
||||
self._stamp = gtf
|
||||
self.value = toGeneralizedTimeFormat(float(gtf))
|
||||
else:
|
||||
self._stamp = fromGeneralizedTimeFormat(gtf)
|
||||
self.value = gtf
|
||||
elif isinstance(gtf, float):
|
||||
self._stamp = gtf
|
||||
self.value = toGeneralizedTimeFormat(gtf)
|
||||
|
||||
@crans_attribute
|
||||
class debutAdhesion(generalizedTimeFormat):
|
||||
legend = u"Date de début de l'adhésion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
ldap_name = 'debutAdhesion'
|
||||
|
||||
|
||||
@crans_attribute
|
||||
class finAdhesion(generalizedTimeFormat):
|
||||
legend = u"Date de fin de l'adhésion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
ldap_name = 'finAdhesion'
|
||||
|
||||
@crans_attribute
|
||||
class debutConnexion(generalizedTimeFormat):
|
||||
legend = u"Date de début de la connexion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
ldap_name = 'debutConnexion'
|
||||
|
||||
@crans_attribute
|
||||
class finConnexion(generalizedTimeFormat):
|
||||
legend = u"Date de fin de la connexion"
|
||||
category = 'Adh'
|
||||
can_modify = [cableur, nounou]
|
||||
ldap_name = 'finConnexion'
|
||||
|
||||
@crans_attribute
|
||||
class mail(Attr):
|
||||
singlevalue = False
|
||||
optional = False
|
||||
unique = True
|
||||
legend = "Adresse mail de l'adhérent"
|
||||
legend = u"Adresse mail de l'adhérent"
|
||||
can_modify = [soi, nounou, cableur]
|
||||
category = 'mail'
|
||||
ldap_name = "mail"
|
||||
|
@ -1446,7 +1521,7 @@ class controle(Attr):
|
|||
ldap_name = "controle"
|
||||
|
||||
def parse_value(self, ctrl):
|
||||
if ctrl not in [u"", u"c", u"p", u"cp", u"pc"]:
|
||||
if ctrl not in [u"", u"c", u"p", u"cp", u"pc", u"TRUE", u"FALSE"]:
|
||||
raise ValueError("Contrôle peut prendre les valeurs [c][p]")
|
||||
self.value = ctrl
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue