示例#1
0
def set_sample_filename(request):
    """
    Set a Sample filename. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == 'POST':
        filename = request.POST.get('filename', None)
        id_ = request.POST.get('id', None)
        analyst = request.user.username
        return HttpResponse(json.dumps(
            update_sample_filename(id_, filename, analyst)),
                            content_type="application/json")
    else:
        error = "Expected POST"
        return render(request, "error.html", {"error": error})
示例#2
0
文件: views.py 项目: armtash/crits
def set_sample_filename(request):
    """
    Set a Sample filename. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == 'POST':
        filename = request.POST.get('filename', None)
        id_ = request.POST.get('id', None)
        analyst = request.user.username
        return HttpResponse(json.dumps(update_sample_filename(id_,
                                                              filename,
                                                              analyst)),
                            content_type="application/json")
    else:
        error = "Expected POST"
        return render(request, "error.html", {"error" : error })
示例#3
0
def set_sample_filename(request):
    """
    Set a Sample filename. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == 'POST':
        filename = request.POST.get('filename', None)
        id_ = request.POST.get('id', None)
        analyst = request.user.username

        result = update_sample_filename(id_, filename, analyst)

        set_releasability_flag('Sample', id_, analyst)

        return HttpResponse(json.dumps(result), mimetype="application/json")
    else:
        error = "Expected POST"
        return render_to_response("error.html", {"error": error},
                                  RequestContext(request))