Example #1
0
def module_info(request, module_location):
    location = Location(module_location)

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    real_method = get_request_method(request)

    rewrite_static_links = request.GET.get('rewrite_url_links',
                                           'True') in ['True', 'true']
    logging.debug('rewrite_static_links = {0} {1}'.format(
        request.GET.get('rewrite_url_links', 'False'), rewrite_static_links))

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    if real_method == 'GET':
        return HttpResponse(json.dumps(
            get_module_info(get_modulestore(location),
                            location,
                            rewrite_static_links=rewrite_static_links)),
                            mimetype="application/json")
    elif real_method == 'POST' or real_method == 'PUT':
        return HttpResponse(json.dumps(
            set_module_info(get_modulestore(location), location,
                            request.POST)),
                            mimetype="application/json")
    else:
        return HttpResponseBadRequest()
def module_info(request, module_location):
    "Get or set information for a module in the modulestore"
    location = Location(module_location)

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    rewrite_static_links = request.GET.get('rewrite_url_links', 'True') in ['True', 'true']
    logging.debug('rewrite_static_links = {0} {1}'.format(
        request.GET.get('rewrite_url_links', False),
        rewrite_static_links)
    )

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    if request.method == 'GET':
        rsp = get_module_info(
            get_modulestore(location),
            location,
            rewrite_static_links=rewrite_static_links
        )
    elif request.method in ("POST", "PUT"):
        rsp = set_module_info(
            get_modulestore(location),
            location, request.POST
        )
    return JsonResponse(rsp)
Example #3
0
def module_info(request, module_location):
    "Get or set information for a module in the modulestore"
    location = Location(module_location)

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    rewrite_static_links = request.GET.get('rewrite_url_links', 'True') in ['True', 'true']
    logging.debug('rewrite_static_links = {0} {1}'.format(
        request.GET.get('rewrite_url_links', False),
        rewrite_static_links)
    )

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    if request.method == 'GET':
        rsp = get_module_info(
            get_modulestore(location),
            location,
            rewrite_static_links=rewrite_static_links
        )
    elif request.method in ("POST", "PUT"):
        rsp = set_module_info(
            get_modulestore(location),
            location, request.POST
        )
    return JsonResponse(rsp)
Example #4
0
def module_info(request, module_location):
    location = Location(module_location)

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    real_method = get_request_method(request)

    rewrite_static_links = request.GET.get('rewrite_url_links', 'True') in ['True', 'true']
    logging.debug('rewrite_static_links = {0} {1}'.format(request.GET.get('rewrite_url_links', 'False'), rewrite_static_links))

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    if real_method == 'GET':
        return HttpResponse(json.dumps(get_module_info(get_modulestore(location), location, rewrite_static_links=rewrite_static_links)), mimetype="application/json")
    elif real_method == 'POST' or real_method == 'PUT':
        return HttpResponse(json.dumps(set_module_info(get_modulestore(location), location, request.POST)), mimetype="application/json")
    else:
        return HttpResponseBadRequest()
Example #5
0
def module_info(request, module_location):
    "Get or set information for a module in the modulestore"
    location = Location(module_location)

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    rewrite_static_links = request.GET.get("rewrite_url_links", "True") in ["True", "true"]
    logging.debug(
        "rewrite_static_links = {0} {1}".format(request.GET.get("rewrite_url_links", "False"), rewrite_static_links)
    )

    # check that logged in user has permissions to this item
    if not has_access(request.user, location):
        raise PermissionDenied()

    if request.method == "GET":
        return JsonResponse(
            get_module_info(get_modulestore(location), location, rewrite_static_links=rewrite_static_links)
        )
    elif request.method in ("POST", "PUT"):
        return JsonResponse(set_module_info(get_modulestore(location), location, request.POST))