def personal(self, request): """Personal ical route.""" calendar_type = constants.TYPE_PERSONAL feed = utils.generate_ical_feed(request, calendar_type) permission_handler = get_permission_handler(Event) following_events = permission_handler.filter_queryset( request.user, Event.objects.filter( followers__follower_id=request.user.id, end_time__gt=timezone.now() - timedelta(days=constants.HISTORY_BACKWARDS_IN_DAYS), ).all(), ) permission_handler = get_permission_handler(Meeting) meetings = permission_handler.filter_queryset( request.user, Meeting.objects.filter( end_time__gt=timezone.now() - timedelta(days=constants.HISTORY_BACKWARDS_IN_DAYS)), ) utils.add_events_to_ical_feed(feed, following_events) utils.add_meetings_to_ical_feed(feed, meetings) return utils.render_ical_response(feed, calendar_type)
def registrations(self, request): """Registration ical route.""" calendar_type = constants.TYPE_REGISTRATIONS feed = utils.generate_ical_feed(request, calendar_type) permission_handler = get_permission_handler(Event) events = permission_handler.filter_queryset( request.user, Event.objects.all().filter(end_time__gt=timezone.now())) for event in events: reg_time = event.get_earliest_registration_time(request.user) if not reg_time: # User cannot register continue ical_starttime = reg_time ical_endtime = ical_starttime + timedelta( minutes=constants.REGISTRATION_EVENT_LENGTH_IN_MINUTES) price = event.get_price(request.user) if event.is_priced else None title = f"Reg: {event.title}" utils.add_event_to_ical_feed( feed, event, price=price, title=title, ical_starttime=ical_starttime, ical_endtime=ical_endtime, ) return utils.render_ical_response(feed, calendar_type)
def events(self, request): """Event ical route.""" calendar_type = constants.TYPE_EVENTS feed = utils.generate_ical_feed(request, calendar_type) permission_handler = get_permission_handler(Event) events = permission_handler.filter_queryset( request.user, Event.objects.all().filter( end_time__gt=timezone.now() - timedelta(days=constants.HISTORY_BACKWARDS_IN_DAYS))) utils.add_events_to_ical_feed(feed, events) return utils.render_ical_response(feed, calendar_type)
def personal(self, request): """Personal ical route.""" calendar_type = constants.TYPE_PERSONAL feed = utils.generate_ical_feed(request, calendar_type) permission_handler = get_permission_handler(Event) following_events = permission_handler.filter_queryset( request.user, Event.objects.filter(followers__follower_id=request.user.id)) permission_handler = get_permission_handler(Meeting) meetings = permission_handler.filter_queryset(request.user, Meeting.objects) utils.add_events_to_ical_feed(feed, following_events) utils.add_meetings_to_ical_feed(feed, meetings) return utils.render_ical_response(feed, calendar_type)