(request)
return render(request, 'taxii_agent_form.html', {'form': form, 'errors': form.errors})
Poll TAXII Feed(s). 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`
Poll TAXII Feed(s). Should be a GET or an AJAX POST.
Poll TAXII Feed ( s ) . Should be a GET or an AJAX POST .
def taxii_poll(request):
    """
    Poll TAXII Feed(s). 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`
    """
    analyst = request.user.username
    form = forms.TAXIIPollForm(analyst, request.POST or None)
    if form.is_valid():
        # Use service configuration from DB.
        feeds = [feed.split(' - ') for feed in form.cleaned_data['feeds']]
        import_all = form.cleaned_data['import_all']
        begin = end = None
        if not form.cleaned_data['use_last']:
            begin = form.cleaned_data['begin']
            end = form.cleaned_data['end']
            if not begin:
                data = {'success': False,
                        'msg': 'Exclusive Begin Timestamp is required'}
                return HttpResponse(json.dumps(data),
                                    content_type="application/json")
        try:
            result = handlers.poll_taxii_feeds(feeds, analyst,
                                               begin, end, import_all)
            data = {'success': True}
            data['html'] = render_to_string("taxii_agent_results.html",
                                            result)
        except Exception as e:
            data = {'success': False, 'msg': str(type(e)) + str(e)}

        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, 'taxii_agent_form.html', {'form': form, 'errors': form.errors})
def taxii_poll ( request ) : analyst = request . user . username form = forms . TAXIIPollForm ( analyst , request . POST or None ) if form . is_valid ( ) : # Use service configuration from DB. feeds = [ feed . split ( ' - ' ) for feed in form . cleaned_data [ 'feeds' ] ] import_all = form . cleaned_data [ 'import_all' ] begin = end = None if not form . cleaned_data [ 'use_last' ] : begin = form . cleaned_data [ 'begin' ] end = form . cleaned_data [ 'end' ] if not begin : data = { 'success' : False , 'msg' : 'Exclusive Begin Timestamp is required' } return HttpResponse ( json . dumps ( data ) , content_type = "application/json" ) try : result = handlers . poll_taxii_feeds ( feeds , analyst , begin , end , import_all ) data = { 'success' : True } data [ 'html' ] = render_to_string ( "taxii_agent_results.html" , result ) except Exception as e : data = { 'success' : False , 'msg' : str ( type ( e ) ) + str ( e ) } 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 , 'taxii_agent_form.html' , { 'form' : form , 'errors' : form . errors } )