From 996839ef70fb20df4c819a4d888c724d1f987af0 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 8 Oct 2020 22:30:15 +0200 Subject: [PATCH] Fix all_adherent and all_has_access function --- re2o/utils.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/re2o/utils.py b/re2o/utils.py index baff6964..89921db6 100644 --- a/re2o/utils.py +++ b/re2o/utils.py @@ -93,13 +93,10 @@ def all_adherent(search_time=None, including_asso=True): search_time = timezone.now() filter_user = Q( facture__in=Facture.objects.filter( - vente__in=Vente.objects.filter( - Q(type_cotisation="All") | Q(type_cotisation="Adhesion"), - cotisation__in=Cotisation.objects.filter( - vente__in=Vente.objects.filter( - facture__in=Facture.objects.all().exclude(valid=False) - ) - ).filter(Q(date_start__lt=search_time) & Q(date_end__gt=search_time)), + vente__cotisation__in=Cotisation.objects.filter( + Q(vente__facture__facture__valid=True) & + Q(date_start_memb__lt=search_time) & + Q(date_end_memb__gt=search_time) ) ) ) @@ -186,15 +183,12 @@ def all_has_access(search_time=None, including_asso=True): ) | Q( facture__in=Facture.objects.filter( - vente__in=Vente.objects.filter( - cotisation__in=Cotisation.objects.filter( - Q(type_cotisation="All") | Q(type_cotisation="Connexion"), - vente__in=Vente.objects.filter( - facture__in=Facture.objects.all().exclude(valid=False) - ), - ).filter( - Q(date_start__lt=search_time) & Q(date_end__gt=search_time) - ) + vente__cotisation__in=Cotisation.objects.filter( + Q(vente__facture__facture__valid=True) & + Q(date_start_con__lt=search_time) & + Q(date_end_con__gt=search_time) & + Q(date_start_memb__lt=search_time) & + Q(date_end_memb__gt=search_time) ) ) )