def endpoint_status_bulk_update(request, fid): if request.method == "POST": post = request.POST endpoints_to_update = post.getlist('endpoints_to_update') status_list = ['active', 'false_positive', 'mitigated', 'out_of_scope', 'risk_accepted'] enable = [item for item in status_list if item in list(post.keys())] if endpoints_to_update and len(enable) > 0: endpoints = Endpoint.objects.filter(id__in=endpoints_to_update).order_by("endpoint_meta__product__id") for endpoint in endpoints: endpoint_status = Endpoint_Status.objects.get( endpoint=endpoint, finding__id=fid) for status in status_list: if status in enable: endpoint_status.__setattr__(status, True) if status == 'mitigated': endpoint_status.mitigated_by = request.user endpoint_status.mitigated_time = timezone.now() else: endpoint_status.__setattr__(status, False) endpoint_status.last_modified = timezone.now() endpoint_status.save() messages.add_message(request, messages.SUCCESS, 'Bulk edit of endpoints was successful. Check to make sure it is what you intended.', extra_tags='alert-success') else: messages.add_message(request, messages.ERROR, 'Unable to process bulk update. Required fields were not selected.', extra_tags='alert-danger') return redirect(request, post['return_url'])
def regen_report(request, rid): report = get_object_or_404(Report, id=rid) if report.type != 'Custom': return redirect(report.options + "®en=" + rid) else: report.datetime = timezone.now() report.status = 'requested' if report.requester.username != request.user.username: report.requester = request.user report.save() async_custom_pdf_report.delay(report=report, template="dojo/custom_pdf_report.html", filename="custom_pdf_report.pdf", host=report_url_resolver(request), user=request.user, uri=request.build_absolute_uri(report.get_url())) messages.add_message(request, messages.SUCCESS, 'Your report is building.', extra_tags='alert-success') return HttpResponseRedirect(reverse('reports'))