diff --git a/objets.py b/objets.py index 136b5cc..499557d 100644 --- a/objets.py +++ b/objets.py @@ -1054,6 +1054,17 @@ class proprio(CransLdapObject): if facture.get('controle', [''])[0] != u"FALSE" and facture.get('recuPaiement', [''])[0] != '' ] + [0.0]) + def adhesion_ok(self, no_bl=False): + """Renvoie si le propriétaire a une adhésion en cours.""" + if self.dn == variables.base_dn: + return True + + fin_paiement = self.fin_adhesion() + + paiement = time.time() < fin_paiement or (config.periode_transitoire and config.debut_periode_transitoire <= fin_paiement <= config.fin_periode_transitoire) + + return paiement + 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. @@ -1061,15 +1072,19 @@ class proprio(CransLdapObject): """ if self.dn == variables.base_dn: return True + if not no_bl: for bl in self.blacklist_actif(): if bl['type'] == 'paiement': return False + if isinstance(self, adherent): fin_paiement = min(self.fin_adhesion(), self.fin_connexion()) else: fin_paiement = self.fin_adhesion() + paiement = time.time() < fin_paiement or (config.periode_transitoire and config.debut_periode_transitoire <= fin_paiement <= config.fin_periode_transitoire) + return paiement def carte_ok(self): diff --git a/printing/templates/templates.py b/printing/templates/templates.py index f71e6bb..7603da5 100644 --- a/printing/templates/templates.py +++ b/printing/templates/templates.py @@ -223,28 +223,42 @@ def list_factures(factures, width=None): width=width) def list_adherents(adherents, width=None): - return tableau([ - [a['aid'][0], - u' '.join(unicode(i) for i in a['prenom'] + a['nom']), - a['chbre'][0], style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'), - u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines()) - ] for a in adherents ], - titre = [u'aid', u'Prénom Nom', u'Chbre', u'P', u'Machines'], - largeur = [5, 35, 5, 1, '*'], - alignement = ['d', 'c', 'c', 'c', 'g'], - width=width) + return tableau( + [ + [ + a['aid'][0], + u' '.join(unicode(i) for i in a['prenom'] + a['nom']), + a['chbre'][0], + style('o', 'vert') if a.adhesion_ok() else style('n', 'rouge'), + style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'), + u', '.join(unicode(m['host'][0]).split('.', 1)[0] for m in a.machines()) + ] + for a in adherents + ], + titre=[u'aid', u'Prénom Nom', u'Chbre', u'A', u'C', u'Machines'], + largeur=[5, 35, 5, 1, 1, '*'], + alignement=['d', 'c', 'c', 'c', 'c', 'g'], + width=width + ) def list_clubs(clubs, width=None): - return tableau([ - [a['cid'][0], - u' '.join(unicode(i) for i in a['nom']), - a['chbre'][0], style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'), - u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines()) - ] for a in clubs ], - titre = [u'cid', u'Nom', u'Chbre', u'P', u'Machines'], - largeur = [5, 35, 5, 1, '*'], - alignement = ['d', 'c', 'c', 'c', 'g'], - width=width) + return tableau( + [ + [ + a['cid'][0], + u' '.join(unicode(i) for i in a['nom']), + a['chbre'][0], + style('o', 'vert') if a.adhesion_ok() else style('n', 'rouge'), + style('o', 'vert') if a.paiement_ok() else style('n', 'rouge'), + u', '.join(unicode(m['host'][0]).split('.',1)[0] for m in a.machines()) + ] + for a in clubs + ], + titre = [u'cid', u'Nom', u'Chbre', u'A', u'C', u'Machines'], + largeur = [5, 35, 5, 1, 1, '*'], + alignement = ['d', 'c', 'c', 'c', 'c', 'g'], + width=width + ) def proprio(proprio, params): params['o']=proprio