def json_lesson_feed(request,location_id=None,room_id=None,show_others=False):
if not request.user or not request.user.is_staff:<EOL><INDENT>raise Http404()<EOL><DEDENT>if not request.user.has_perm('<STR_LIT>'):<EOL><INDENT>show_others = False<EOL><DEDENT>this_instructor = getattr(request.user,'<STR_LIT>',None)<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>filters = Q(instructoravailabilityslot__status=InstructorAvailabilitySlot.SlotStatus.booked)<EOL>if not show_others:<EOL><INDENT>filters = filters & Q(eventstaffmember__staffMember=this_instructor)<EOL><DEDENT>if startDate:<EOL><INDENT>filters = filters & Q(startTime__gte=ensure_timezone(datetime.strptime(startDate,'<STR_LIT>')))<EOL><DEDENT>if endDate:<EOL><INDENT>filters = filters & Q(endTime__lte=ensure_timezone(datetime.strptime(endDate,'<STR_LIT>')) + timedelta(days=<NUM_LIT:1>))<EOL><DEDENT>if location_id:<EOL><INDENT>filters = filters & Q(location__id=location_id)<EOL><DEDENT>if room_id:<EOL><INDENT>filters = filters & Q(room_id=room_id)<EOL><DEDENT>lessons = PrivateLessonEvent.objects.filter(filters).distinct()<EOL>eventlist = [PrivateLessonFeedItem(x,timeZone=timeZone).__dict__ for x in lessons]<EOL>return JsonResponse(eventlist,safe=False)<EOL>
This function displays a JSON feed of all lessons scheduled, optionally
filtered by location. If show_others is specified, it requires that the
user has permission to see all other instructor's lessons as well.