def json_event_feed(request,location_id=None,room_id=None):
if not getConstant('<STR_LIT>') or not request.user.is_staff:<EOL><INDENT>return JsonResponse({})<EOL><DEDENT>this_user = request.user<EOL>startDate = request.GET.get('<STR_LIT:start>','<STR_LIT>')<EOL>endDate = request.GET.get('<STR_LIT:end>','<STR_LIT>')<EOL>timeZone = request.GET.get('<STR_LIT>',getattr(settings,'<STR_LIT>','<STR_LIT>'))<EOL>time_filter_dict_events = {}<EOL>if startDate:<EOL><INDENT>time_filter_dict_events['<STR_LIT>'] = ensure_timezone(datetime.strptime(startDate,'<STR_LIT>'))<EOL><DEDENT>if endDate:<EOL><INDENT>time_filter_dict_events['<STR_LIT>'] = ensure_timezone(datetime.strptime(endDate,'<STR_LIT>')) + timedelta(days=<NUM_LIT:1>)<EOL><DEDENT>instructor_groups = list(this_user.groups.all().values_list('<STR_LIT:id>',flat=True))<EOL>filters = Q(event__privateevent__isnull=False) & (<EOL>Q(event__privateevent__displayToGroup__in=instructor_groups) |<EOL>Q(event__privateevent__displayToUsers=this_user) |<EOL>(Q(event__privateevent__displayToGroup__isnull=True) & Q(event__privateevent__displayToUsers__isnull=True))<EOL>)<EOL>if location_id:<EOL><INDENT>filters = filters & Q(event__location__id=location_id)<EOL><DEDENT>if room_id:<EOL><INDENT>filters = filters & Q(event__room_id=room_id)<EOL><DEDENT>occurrences = EventOccurrence.objects.filter(filters).filter(**time_filter_dict_events).order_by('<STR_LIT>')<EOL>eventlist = [EventFeedItem(x,timeZone=timeZone).__dict__ for x in occurrences]<EOL>return JsonResponse(eventlist,safe=False)<EOL>
The Jquery fullcalendar app requires a JSON news feed, so this function
creates the feed from upcoming PrivateEvent objects