From 9583cec3ff41d7c728d2107059e9caff0b6b47a2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 16 Sep 2021 21:10:23 +0200 Subject: [PATCH] [WEI] Fix quotas Signed-off-by: Yohann D'ANELLO --- apps/wei/forms/surveys/wei2021.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/wei/forms/surveys/wei2021.py b/apps/wei/forms/surveys/wei2021.py index a046b7ea..5b7d4530 100644 --- a/apps/wei/forms/surveys/wei2021.py +++ b/apps/wei/forms/surveys/wei2021.py @@ -204,13 +204,21 @@ class WEISurveyAlgorithm2021(WEISurveyAlgorithm): # Repartition for non men people first self.make_repartition(non_men, quotas, tqdm_obj=tqdm_obj) + quotas = {} + for bus in self.get_buses(): + free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count() + free_seats -= sum(1 for s in non_men if s.information.selected_bus_pk == bus.pk) + quotas[bus] = free_seats + + print(quotas) + if display_tqdm: tqdm_obj.close() from tqdm import tqdm tqdm_obj = tqdm(total=len(men), desc="Hommes") - self.make_repartition(men, tqdm_obj=tqdm_obj) + self.make_repartition(men, quotas, tqdm_obj=tqdm_obj) if display_tqdm: tqdm_obj.close()