Load events for the month view

This commit is contained in:
2018-06-29 16:14:35 +02:00
parent bac17faed2
commit a25e869eca
2 changed files with 19 additions and 3 deletions

View File

@@ -46,3 +46,19 @@ class GregorianCalendar(CalendarSystem):
day_list.append(current_day)
return day_list
def day_events(self, date, user=None):
from app.models import Event
events = Event.query
if user:
events = events.filter(Event.user == user)
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
end_timestamp = start_timestamp + timedelta(days=1)
events = events.filter(((Event.start_time >= start_timestamp) & (Event.start_time < end_timestamp)) |
((Event.end_time >= start_timestamp) & (Event.end_time < end_timestamp)))
return events