def export(request): """ :param request: :return: """ if request.method == 'POST': scan_id = request.POST.get("scan_id") report_type = request.POST.get("type") netsparker_resource = NetsparkerResource() queryset = netsparker_scan_result_db.objects.filter(scan_id=scan_id) dataset = netsparker_resource.export(queryset) if report_type == 'csv': response = HttpResponse(dataset.csv, content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename="%s.csv"' % scan_id return response if report_type == 'json': response = HttpResponse(dataset.json, content_type='application/json') response[ 'Content-Disposition'] = 'attachment; filename="%s.json"' % scan_id return response if report_type == 'yaml': response = HttpResponse(dataset.yaml, content_type='application/x-yaml') response[ 'Content-Disposition'] = 'attachment; filename="%s.yaml"' % scan_id return response
def export(request): """ :param request: :return: """ username = request.user.username if request.method == 'POST': scan_id = request.POST.get("scan_id") report_type = request.POST.get("type") scan_item = str(scan_id) value = scan_item.replace(" ", "") value_split = value.split(',') netsparker_resource = NetsparkerResource() queryset = netsparker_scan_result_db.objects.filter( username=username, scan_id__in=value_split) dataset = netsparker_resource.export(queryset) if report_type == 'csv': response = HttpResponse(dataset.csv, content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename="%s.csv"' % 'netsparker_results' return response if report_type == 'json': response = HttpResponse(dataset.json, content_type='application/json') response[ 'Content-Disposition'] = 'attachment; filename="%s.json"' % 'netsparker_results' return response if report_type == 'yaml': response = HttpResponse(dataset.yaml, content_type='application/x-yaml') response[ 'Content-Disposition'] = 'attachment; filename="%s.yaml"' % 'netsparker_results' return response