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:
parent
a29c9ae6af
commit
bb4bd60b1b
@ -19,7 +19,7 @@ def daterange(start, end, step=timedelta(1)):
|
||||
|
||||
|
||||
class DayInCalendar:
|
||||
midnight = time(23, 59, 59)
|
||||
midnight = time(0, 0, 0)
|
||||
|
||||
def __init__(self, d, on_requested_interval=True):
|
||||
self.date = d
|
||||
@ -74,15 +74,29 @@ class DayInCalendar:
|
||||
|
||||
def _add_event_internal(self, event):
|
||||
from .models import Category
|
||||
from copy import deepcopy
|
||||
# copy event
|
||||
local_event = deepcopy(event)
|
||||
|
||||
self.events.append(event)
|
||||
if event.category is None:
|
||||
# set values
|
||||
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
|
||||
else:
|
||||
cat = event.category.name
|
||||
cat = local_event.category.name
|
||||
if cat not in self.events_by_category:
|
||||
self.events_by_category[cat] = []
|
||||
self.events_by_category[cat].append(event)
|
||||
self.events_by_category[cat].append(local_event)
|
||||
|
||||
def filter_events(self):
|
||||
self.events.sort(
|
||||
|
Loading…
Reference in New Issue
Block a user