Load events for the month view
This commit is contained in:
parent
bac17faed2
commit
a25e869eca
@ -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
|
||||
|
@ -70,11 +70,11 @@
|
||||
{%- endif %}
|
||||
<td class="{% if day.month != calendar.timestamp.month %} other-month{% endif %}{% if day.date() == calendar.timestamp.date() %} today{% endif %}">
|
||||
<span class="day-num">{{ day.day }}</span>
|
||||
{% if day.date() == calendar.timestamp.date() %}
|
||||
{% for event in calendar.day_events(day, user=current_user) %}
|
||||
<div class="event">
|
||||
This is a task
|
||||
{{ event.title }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user