forked from gergely/calendar-social
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user