From cf4c63de7010ae643becc46e7558c0b29545bb9d Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 19 Feb 2014 19:04:34 +0100 Subject: [PATCH] =?UTF-8?q?[objets]=20Simplification=20de=20paiement=5Fok?= =?UTF-8?q?=20carte=5Fok=20et=20cie=20du=20=C3=A0=20l'ajouts=20de=20methde?= =?UTF-8?q?s=20sur=20Attr=20cette=20derni=C3=A8re=20semaine.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objets.py | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/objets.py b/objets.py index e1b4d4a..7ebc0d5 100644 --- a/objets.py +++ b/objets.py @@ -499,17 +499,16 @@ class CransLdapObject(object): if not self.carte_ok(): bl = attributs.blacklist(u'%s$%s$%s$%s' % ('-', '-', 'carte_etudiant', ''), {}, self.conn) 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) blacklist_liste.append(bl) 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) blacklist_liste.append(bl) - attrs = (self.attrs if self.mode not in ["w", "rw"] else self._modifs) - blacklist_liste.extend(filter((lambda bl: bl.is_actif()), attrs.get("blacklist",[]))) + blacklist_liste.extend(bl for bl in self.get("blacklist", []) if bl.is_actif()) 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: 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""" return self.paiement_ok() and self.carte_ok() - - def paiement_ok(self): - u"""Renvoie si le propriétaire a payé pour l'année en cours, en prenant en compte les périodes de transition""" + def paiement_ok(self, no_bl=False): + u""" + 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: return True - bool_paiement = False - try: - for paiement in self['paiement']: - if paiement.value == config.ann_scol: - bool_paiement = True - 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 + if not no_bl: + for bl in self.blacklist_actif(): + if bl['type'] == 'paiement': + return False + return config.ann_scol in self['paiement'] or (config.periode_transitoire and (config.ann_scol - 1) in self['paiement']) 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""" - 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"]): - 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 + if self.dn == variables.base_dn: + 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 def update_solde(self, diff, comment=u"", login=None):