From 4ea0093c8ec65625faca15305b5c4b155921bf81 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Mon, 6 Nov 2023 09:08:32 +0100 Subject: [PATCH] correction de bugs --- src/agenda_culturel/views.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 3acdeda..e879ff3 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -62,6 +62,7 @@ class CalendarList: def __init__(self, firstdate, lastdate): self.firstdate = firstdate self.lastdate = lastdate + self.now = date.today() # start the first day of the first week self.c_firstdate = firstdate + timedelta(days=-firstdate.weekday()) @@ -77,16 +78,10 @@ class CalendarList: def today_in_calendar(self): - for d in self.calendar_days.values(): - if not d.is_today(): - return True - return False + return self.firstdate <= self.now and self.lastdate >= self.now def all_in_past(self): - for d in self.calendar_days.values(): - if not d.is_in_past(): - return False - return True + return self.lastdate < self.now def fill_calendar_days(self): self.events = Event.objects.filter(start_day__lte=self.c_lastdate, start_day__gte=self.c_firstdate).order_by("start_day", "start_time")