Les timestamps c'est merdique, maintenant tout est du datetime
This commit is contained in:
parent
4de62cd0a8
commit
a1f27f9f1a
3 changed files with 64 additions and 43 deletions
47
objets.py
47
objets.py
|
@ -1038,33 +1038,42 @@ class proprio(CransLdapObject):
|
|||
def fin_adhesion(self):
|
||||
"""Retourne la date de fin d'adhésion"""
|
||||
return max([
|
||||
float(facture.get('finAdhesion', [crans_utils.from_generalized_time_format(attributs.finAdhesion.default)])[0])
|
||||
facture.get('finAdhesion', [attributs.finAdhesion.default])[0]
|
||||
for facture in self.factures(refresh=(time.time() - self._factures_last_update > FACTURES_REFRESH_PERIOD))
|
||||
if facture.get('controle', [''])[0] != u"FALSE" and facture.get('recuPaiement', [])
|
||||
] + [0.0])
|
||||
|
||||
def fin_connexion_datetime(self):
|
||||
return datetime.datetime.fromtimestamp(self.fin_connexion())
|
||||
|
||||
def fin_adhesion_datetime(self):
|
||||
return datetime.datetime.fromtimestamp(self.fin_adhesion())
|
||||
] + [attributs.finAdhesion.default])
|
||||
|
||||
def fin_connexion(self):
|
||||
"""Retourne la date de fin de connexion"""
|
||||
return max([
|
||||
float(facture.get('finConnexion', [crans_utils.from_generalized_time_format(attributs.finConnexion.default)])[0])
|
||||
facture.get('finConnexion', [attributs.finConnexion.default])[0]
|
||||
for facture in self.factures(refresh=(time.time() - self._factures_last_update > FACTURES_REFRESH_PERIOD))
|
||||
if facture.get('controle', [''])[0] != u"FALSE" and facture.get('recuPaiement', [])
|
||||
] + [0.0])
|
||||
] + [attributs.finConnexion.default])
|
||||
|
||||
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
|
||||
|
||||
_now = crans_utils.localized_datetime()
|
||||
|
||||
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)
|
||||
paiement = (
|
||||
_now < fin_paiement
|
||||
or
|
||||
(
|
||||
config.periode_transitoire
|
||||
and
|
||||
(
|
||||
crans_utils.datetime_from_generalized_time_format(config.gtf_debut_periode_transitoire)
|
||||
<= fin_paiement
|
||||
<= crans_utils.datetime_from_generalized_time_format(config.gtf_fin_periode_transitoire)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return paiement
|
||||
|
||||
|
@ -1081,12 +1090,26 @@ class proprio(CransLdapObject):
|
|||
if bl['type'] == 'paiement':
|
||||
return False
|
||||
|
||||
_now = crans_utils.localized_datetime()
|
||||
|
||||
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)
|
||||
paiement = (
|
||||
_now < fin_paiement
|
||||
or
|
||||
(
|
||||
config.periode_transitoire
|
||||
and
|
||||
(
|
||||
crans_utils.datetime_from_generalized_time_format(config.gtf_debut_periode_transitoire)
|
||||
<= fin_paiement
|
||||
<= crans_utils.datetime_from_generalized_time_format(config.gtf_fin_periode_transitoire)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return paiement
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue