Fix erreur dans l'import (visible avec le fotomat)

This commit is contained in:
Jean-Marie Favreau 2024-11-27 11:04:34 +01:00
parent 2680622dfc
commit f9678bbf81

View File

@ -689,7 +689,9 @@ class Event(models.Model):
if intuitive:
end_day = self.get_consolidated_end_day(False)
if end_day != self.start_day and self.end_time and self.end_time < time(8):
return end_day + timedelta(days=-1)
if isinstance(end_day, str):
end_day = date.fromisoformat(str(end_day))
return parse_date(end_day) + timedelta(days=-1)
else:
return end_day
else:
@ -713,7 +715,10 @@ class Event(models.Model):
return self.start_day == self.get_consolidated_end_day(intuitive)
def is_event_long_duration(self, min_days=4, intuitive=True):
return parse_date(self.start_day) + timedelta(days=min_days) < parse_date(self.get_consolidated_end_day(intuitive))
end_date = self.get_consolidated_end_day(intuitive)
if isinstance(end_date, str):
end_date = parse_date(end_date)
return parse_date(self.start_day) + timedelta(days=min_days) < end_date
def contains_date(self, d, intuitive=True):
return d >= self.start_day and d <= self.get_consolidated_end_day(intuitive)