def complete_checklist(request, eid): eng = get_object_or_404(Engagement, id=eid) add_breadcrumb(parent=eng, title="Complete checklist", top_level=False, request=request) if request.method == 'POST': tests = Test.objects.filter(engagement=eng) findings = Finding.objects.filter(test__in=tests).all() form = CheckForm(request.POST, findings=findings) if form.is_valid(): cl = form.save(commit=False) try: check_l = Check_List.objects.get(engagement=eng) cl.id = check_l.id cl.save() form.save_m2m() except: cl.engagement = eng cl.save() form.save_m2m() pass messages.add_message(request, messages.SUCCESS, 'Checklist saved.', extra_tags='alert-success') return HttpResponseRedirect( reverse('view_engagement', args=(eid, ))) else: tests = Test.objects.filter(engagement=eng) findings = Finding.objects.filter(test__in=tests).all() form = CheckForm(findings=findings) product_tab = Product_Tab(eng.product.id, title="Checklist", tab="engagements") product_tab.setEngagement(eng) return render( request, 'dojo/checklist.html', { 'form': form, 'product_tab': product_tab, 'eid': eng.id, 'findings': findings, })
def complete_checklist(request, eid): eng = get_object_or_404(Engagement, id=eid) add_breadcrumb( parent=eng, title="Complete checklist", top_level=False, request=request) if request.method == 'POST': tests = Test.objects.filter(engagement=eng) findings = Finding.objects.filter(test__in=tests).all() form = CheckForm(request.POST, findings=findings) if form.is_valid(): cl = form.save(commit=False) try: check_l = Check_List.objects.get(engagement=eng) cl.id = check_l.id cl.save() form.save_m2m() except: cl.engagement = eng cl.save() form.save_m2m() pass messages.add_message( request, messages.SUCCESS, 'Checklist saved.', extra_tags='alert-success') return HttpResponseRedirect( reverse('view_engagement', args=(eid, ))) else: tests = Test.objects.filter(engagement=eng) findings = Finding.objects.filter(test__in=tests).all() form = CheckForm(findings=findings) product_tab = Product_Tab(eng.product.id, title="Checklist", tab="engagements") product_tab.setEngagement(eng) return render(request, 'dojo/checklist.html', { 'form': form, 'product_tab': product_tab, 'eid': eng.id, 'findings': findings, })