def index_list(request):
    state_temp = []
    district_temp = []
    district_name = {}
    district_list = []
    
    courses = get_courses(request.user, request.META.get('HTTP_HOST'))
    courses = sort_by_custom(courses)
    
    for course in courses:
        if request.user.is_superuser is False:
            if request.user.profile.district.state.name in course.display_state:
                state_temp.append(request.user.profile.district.state.name)

            if request.user.profile.district.code in course.display_district:
                district = District.objects.filter(code=request.user.profile.district.code)[0]
                district_temp.append(request.user.profile.district.code)
                district_name[request.user.profile.district.code] = district.name
        else:
            if len(course.display_state) > 0 and is_all(course, 'state') is False:
                state_temp.extend(course.display_state)

            if len(course.display_district) > 0 and is_all(course, 'district') is False:
                districts = District.objects.filter(code__in=course.display_district)
                district_temp.extend(course.display_district)
                for district in districts:
                    district_name[district.code] = district.name

        state_list = sorted(set(state_temp), key=lambda x: x[0])
        district_temp = sorted(set(district_temp), key=lambda x: x[0])
        for dl in district_temp:
            district_list.append({'id': dl, 'name': district_name[dl]})
    
    return render_to_response('access_resource_library_list.html', {
                                                          "states": state_list,
                                                          "districts": district_list})
def get_course_list(request):
    courses = sort_by_custom(get_courses(request.user))
    returnInfo=[]
    for course in courses:
        returnInfo.append({"id":course.id,"name":course.display_name,"location":str(course.location)})
    return JsonResponse(returnInfo)