(request)
return render(request, 'stix_upload_form.html', {'form': form, 'errors': form.errors})
Manually upload a STIX document or ZIP of STIX documents.
    Should be a GET or an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
Manually upload a STIX document or ZIP of STIX documents.
    Should be a GET or an AJAX POST.
Manually upload a STIX document or ZIP of STIX documents . Should be a GET or an AJAX POST .
def stix_upload(request):
    """
    Manually upload a STIX document or ZIP of STIX documents.
    Should be a GET or an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """
    if request.method == "POST":
        form = forms.UploadStandardsForm(request.user, request.POST, request.FILES)
    else:
        form = forms.UploadStandardsForm(request.user)

    if form.is_valid():
        filedata = request.FILES['filedata']
        analyst = request.user.username
        source = form.cleaned_data['source']
        reference = form.cleaned_data['reference']
        use_hdr_src = form.cleaned_data['use_hdr_src']
        import_all = form.cleaned_data['import_all']

        result = handlers.process_stix_upload(filedata, analyst, source,
                                              reference, use_hdr_src,
                                              import_all)
        if import_all:
            data = {'success': True, 'imported': True}
            data['html'] = render_to_string("taxii_agent_results.html",
                                            {'imported' : result})
        else:
            data = {'success': True}
            data['html'] = render_to_string("taxii_agent_preview.html",
                                            {'poll': result})

        return HttpResponse(json.dumps(data), content_type="application/json")

    if request.is_ajax():
        msg = "<b>Form Validation Error</b><br>"
        for fld in form.errors:
            msg += "%s: %s<br>" % (form[fld].label,
                                   form.errors[fld].as_text())
        data = {'success': False, 'msg': msg}
        return HttpResponse(json.dumps(data), content_type="application/json")

    return render(request, 'stix_upload_form.html', {'form': form, 'errors': form.errors})
def stix_upload ( request ) : if request . method == "POST" : form = forms . UploadStandardsForm ( request . user , request . POST , request . FILES ) else : form = forms . UploadStandardsForm ( request . user ) if form . is_valid ( ) : filedata = request . FILES [ 'filedata' ] analyst = request . user . username source = form . cleaned_data [ 'source' ] reference = form . cleaned_data [ 'reference' ] use_hdr_src = form . cleaned_data [ 'use_hdr_src' ] import_all = form . cleaned_data [ 'import_all' ] result = handlers . process_stix_upload ( filedata , analyst , source , reference , use_hdr_src , import_all ) if import_all : data = { 'success' : True , 'imported' : True } data [ 'html' ] = render_to_string ( "taxii_agent_results.html" , { 'imported' : result } ) else : data = { 'success' : True } data [ 'html' ] = render_to_string ( "taxii_agent_preview.html" , { 'poll' : result } ) return HttpResponse ( json . dumps ( data ) , content_type = "application/json" ) if request . is_ajax ( ) : msg = "<b>Form Validation Error</b><br>" for fld in form . errors : msg += "%s: %s<br>" % ( form [ fld ] . label , form . errors [ fld ] . as_text ( ) ) data = { 'success' : False , 'msg' : msg } return HttpResponse ( json . dumps ( data ) , content_type = "application/json" ) return render ( request , 'stix_upload_form.html' , { 'form' : form , 'errors' : form . errors } )