Beispiel #1
0
def delete_template(request, tid):
    template = get_object_or_404(Finding_Template, id=tid)

    form = DeleteFindingTemplateForm(instance=template)

    if request.method == 'POST':
        form = DeleteFindingTemplateForm(request.POST, instance=template)
        if form.is_valid():
            template.delete()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Finding Template deleted successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('templates'))
        else:
            messages.add_message(request,
                                 messages.ERROR,
                                 'Unable to delete Template, please revise and try again.',
                                 extra_tags='alert-danger')
    else:
        return HttpResponseForbidden()
Beispiel #2
0
def delete_template(request, tid):
    template = get_object_or_404(Finding_Template, id=tid)

    form = DeleteFindingTemplateForm(instance=template)

    if request.method == 'POST':
        form = DeleteFindingTemplateForm(request.POST, instance=template)
        if form.is_valid():
            del template.tags
            template.delete()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Finding Template deleted successfully.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('templates'))
        else:
            messages.add_message(request,
                                 messages.ERROR,
                                 'Unable to delete Template, please revise and try again.',
                                 extra_tags='alert-danger')
    else:
        return HttpResponseForbidden()