[objets] Simplification de paiement_ok carte_ok et cie du à l'ajouts de methdes sur Attr cette dernière semaine.
This commit is contained in:
parent
fa8aef7d18
commit
cf4c63de70
1 changed files with 22 additions and 33 deletions
53
objets.py
53
objets.py
|
@ -499,17 +499,16 @@ class CransLdapObject(object):
|
||||||
if not self.carte_ok():
|
if not self.carte_ok():
|
||||||
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'carte_etudiant', ''), {}, self.conn)
|
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'carte_etudiant', ''), {}, self.conn)
|
||||||
blacklist_liste.append(bl)
|
blacklist_liste.append(bl)
|
||||||
if self['chbre'][0].value == '????':
|
if self['chbre'][0] == '????':
|
||||||
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'chambre_invalide', ''), {}, self.conn)
|
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'chambre_invalide', ''), {}, self.conn)
|
||||||
blacklist_liste.append(bl)
|
blacklist_liste.append(bl)
|
||||||
if isinstance(self, proprio):
|
if isinstance(self, proprio):
|
||||||
if not self.paiement_ok():
|
if not self.paiement_ok(no_bl=True):
|
||||||
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'paiement', ''), {}, self.conn)
|
bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'paiement', ''), {}, self.conn)
|
||||||
blacklist_liste.append(bl)
|
blacklist_liste.append(bl)
|
||||||
attrs = (self.attrs if self.mode not in ["w", "rw"] else self._modifs)
|
blacklist_liste.extend(bl for bl in self.get("blacklist", []) if bl.is_actif())
|
||||||
blacklist_liste.extend(filter((lambda bl: bl.is_actif()), attrs.get("blacklist",[])))
|
|
||||||
if excepts:
|
if excepts:
|
||||||
return [ b for b in blacklist_liste if b.value['type'] not in excepts ]
|
return [ b for b in blacklist_liste if b['type'] not in excepts ]
|
||||||
else:
|
else:
|
||||||
return blacklist_liste
|
return blacklist_liste
|
||||||
|
|
||||||
|
@ -592,39 +591,29 @@ class proprio(CransLdapObject):
|
||||||
u"""Renvoie si le propriétaire a payé et donné sa carte pour l'année en cours"""
|
u"""Renvoie si le propriétaire a payé et donné sa carte pour l'année en cours"""
|
||||||
return self.paiement_ok() and self.carte_ok()
|
return self.paiement_ok() and self.carte_ok()
|
||||||
|
|
||||||
|
def paiement_ok(self, no_bl=False):
|
||||||
def paiement_ok(self):
|
u"""
|
||||||
u"""Renvoie si le propriétaire a payé pour l'année en cours, en prenant en compte les périodes de transition"""
|
Renvoie si le propriétaire a payé pour l'année en cours, en prenant en compte les périodes de transition et les blacklistes.
|
||||||
|
``no_bl`` ne devrait être utilisé que par la fonction blacklist_actif lors de la construction des blacklistes virtuelles
|
||||||
|
"""
|
||||||
if self.dn == variables.base_dn:
|
if self.dn == variables.base_dn:
|
||||||
return True
|
return True
|
||||||
bool_paiement = False
|
if not no_bl:
|
||||||
try:
|
for bl in self.blacklist_actif():
|
||||||
for paiement in self['paiement']:
|
if bl['type'] == 'paiement':
|
||||||
if paiement.value == config.ann_scol:
|
return False
|
||||||
bool_paiement = True
|
return config.ann_scol in self['paiement'] or (config.periode_transitoire and (config.ann_scol - 1) in self['paiement'])
|
||||||
break
|
|
||||||
# Pour la période transitoire année précédente ok
|
|
||||||
if config.periode_transitoire and paiement.value == (config.ann_scol -1):
|
|
||||||
bool_paiement = True
|
|
||||||
break
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
return bool_paiement
|
|
||||||
|
|
||||||
def carte_ok(self):
|
def carte_ok(self):
|
||||||
u"""Renvoie si le propriétaire a donné sa carte pour l'année en cours, en prenant en compte les periode transitoires et le sursis carte"""
|
u"""Renvoie si le propriétaire a donné sa carte pour l'année en cours, en prenant en compte les periode transitoires et le sursis carte"""
|
||||||
if not self.dn == variables.base_dn and not config.periode_transitoire and config.bl_carte_et_actif and not 'club' in map(lambda x:x.value,self["objectClass"]):
|
if self.dn == variables.base_dn:
|
||||||
bool_carte = False
|
|
||||||
try:
|
|
||||||
for carte in self['carteEtudiant']:
|
|
||||||
if carte.value == config.ann_scol:
|
|
||||||
bool_carte = True
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
if not bool_carte and self.sursis_carte():
|
|
||||||
bool_carte = True
|
|
||||||
return bool_carte
|
|
||||||
return True
|
return True
|
||||||
|
elif 'club' in self["objectClass"]:
|
||||||
|
return True
|
||||||
|
elif config.periode_transitoire or not config.bl_carte_et_actif:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return config.ann_scol in self.get('carteEtudiant', []) or self.sursis_carte()
|
||||||
|
|
||||||
# XXX - To Delete
|
# XXX - To Delete
|
||||||
def update_solde(self, diff, comment=u"", login=None):
|
def update_solde(self, diff, comment=u"", login=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue