Correction de la gestion des événements dans un jour

- correction de l'ordre (sans heure en premier)
- Fix #154
This commit is contained in:
Jean-Marie Favreau 2024-09-21 19:02:56 +02:00
parent a29c9ae6af
commit bb4bd60b1b

View File

@ -19,7 +19,7 @@ def daterange(start, end, step=timedelta(1)):
class DayInCalendar: class DayInCalendar:
midnight = time(23, 59, 59) midnight = time(0, 0, 0)
def __init__(self, d, on_requested_interval=True): def __init__(self, d, on_requested_interval=True):
self.date = d self.date = d
@ -74,15 +74,29 @@ class DayInCalendar:
def _add_event_internal(self, event): def _add_event_internal(self, event):
from .models import Category from .models import Category
from copy import deepcopy
# copy event
local_event = deepcopy(event)
self.events.append(event) # set values
if event.category is None: if local_event.start_day != self.date:
local_event.start_day = self.date
local_event.start_time = None
if local_event.end_day != self.date:
local_event.end_day = None
local_event.end_time = None
# add event to the day
self.events.append(local_event)
# add in its category
if local_event.category is None:
cat = Category.default_name cat = Category.default_name
else: else:
cat = event.category.name cat = local_event.category.name
if cat not in self.events_by_category: if cat not in self.events_by_category:
self.events_by_category[cat] = [] self.events_by_category[cat] = []
self.events_by_category[cat].append(event) self.events_by_category[cat].append(local_event)
def filter_events(self): def filter_events(self):
self.events.sort( self.events.sort(