Add the Event.visibility field

This shows if the event is visible to anyone or just people who are invited.

The calendar view already respects this flag.
This commit is contained in:
2018-07-16 12:12:35 +02:00
parent f2f7ef72dd
commit a862e6ca5d
4 changed files with 66 additions and 2 deletions

View File

@@ -199,12 +199,14 @@ class GregorianCalendar(CalendarSystem):
"""Returns all events for a given day
"""
from ..models import Event, Profile
from ..models import Event, EventVisibility, Invitation, Profile, Response
events = Event.query
if user:
events = events.join(Profile) \
events = events.outerjoin(Invitation) \
.outerjoin(Response) \
.join(Profile, Event.profile) \
.filter(Profile.user == user)
start_timestamp = date.replace(hour=0, minute=0, second=0, microsecond=0)
@@ -216,4 +218,12 @@ class GregorianCalendar(CalendarSystem):
(Event.end_time < end_timestamp))) \
.order_by('start_time', 'end_time')
if user is None:
events = events.filter(Event.visibility == EventVisibility.public)
else:
events = events.filter((Event.visibility == EventVisibility.public) |
(Event.profile == user.profile) |
(Invitation.invitee == user.profile) |
(Response.profile == user.profile))
return events