コード例 #1
0
ファイル: views.py プロジェクト: vsbca/crits
def indicator_from_object(request):
    """
    Create an indicator out of an object. Should be an AJAX POST.

    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == "POST" and request.is_ajax():
        rel_type = request.POST.get('rel_type', None)
        rel_id = request.POST.get('rel_id', None)
        ind_type = request.POST.get('ind_type', None)
        value = request.POST.get('value', None)
        source = request.POST.get('source', None)
        method = request.POST.get('method', None)
        reference = request.POST.get('reference', None)
        tlp = request.POST.get('tlp', None)
        analyst = request.user.username

        result = create_indicator_from_object(rel_type, rel_id, ind_type,
                                              value, source, method, reference,
                                              tlp, analyst, request)
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render_to_response("error.html", {"error": error},
                                  RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: 971sec/crits
def indicator_from_object(request):
    """
    Create an indicator out of an object. Should be an AJAX POST.

    :param request: The Django request.
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == "POST" and request.is_ajax():
        rel_type = request.POST.get('rel_type', None)
        rel_id = request.POST.get('rel_id', None)
        ind_type = request.POST.get('ind_type', None)
        value = request.POST.get('value', None)
        source = request.POST.get('source', None)
        method = request.POST.get('method', None)
        reference = request.POST.get('reference', None)
        analyst = "%s" % request.user.username
        result = create_indicator_from_object(rel_type,
                                              rel_id,
                                              ind_type,
                                              value,
                                              source,
                                              method,
                                              reference,
                                              analyst,
                                              request)
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render_to_response("error.html",
                                  {"error" : error },
                                  RequestContext(request))