Example #1
0
def edit_backdoor_version(request, id_):
    """
    Set backdoor version. Should be an AJAX POST.

    :param request: Django request.
    :type request: :class:`django.http.HttpRequest`
    :param id_: The ObjectId of the Backdoor.
    :type id_: str
    :returns: :class:`django.http.HttpResponseRedirect`
    """

    if request.method == "POST" and request.is_ajax():
        user = request.user.username
        version = request.POST.get('version', None)
        if version == None:
            return HttpResponse(json.dumps({
                'success': False,
                'message': 'Not all info provided.'
            }),
                                content_type="application/json")
        result = set_backdoor_version(id_, version, user)
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render_to_response("error.html", {"error": error},
                                  RequestContext(request))
Example #2
0
def edit_backdoor_version(request, id_):
    """
    Set backdoor version. Should be an AJAX POST.

    :param request: Django request.
    :type request: :class:`django.http.HttpRequest`
    :param id_: The ObjectId of the Backdoor.
    :type id_: str
    :returns: :class:`django.http.HttpResponseRedirect`
    """

    if request.method == "POST" and request.is_ajax():
        user = request.user.username
        version = request.POST.get('version', None)
        if version == None:
            return HttpResponse(json.dumps({'success': False,
                                            'message': 'Not all info provided.'}),
                                content_type="application/json")
        result = set_backdoor_version(id_, version, user)
        return HttpResponse(json.dumps(result), content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render_to_response("error.html",
                                  {"error" : error },
                                  RequestContext(request))