Beispiel #1
0
def reasons_add(request):
    if request.method == 'POST':
        form = ReasonForm(request.POST)
        if form.is_valid():
            reason = form.save(commit=False)
            reason.save()
            reason.logger(str(request.user), " REASON_ADD_EXECUTED")
            messages.success(request, 'Reason added')
            return redirect('/reasons')
    else:
        form = ReasonForm()
        debug_logger(str(request.user), " REASON_ADD_ENTERED")
    return render(request, 'dfirtrack_main/reason/reasons_add.html',
                  {'form': form})
Beispiel #2
0
def reasons_edit(request, pk):
    reason = get_object_or_404(Reason, pk=pk)
    if request.method == 'POST':
        form = ReasonForm(request.POST, instance=reason)
        if form.is_valid():
            reason = form.save(commit=False)
            reason.save()
            reason.logger(str(request.user), " REASON_EDIT_EXECUTED")
            messages.success(request, 'Reason edited')
            return redirect('/reasons')
    else:
        form = ReasonForm(instance=reason)
        reason.logger(str(request.user), " REASON_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/reason/reasons_edit.html',
                  {'form': form})
Beispiel #3
0
def reasons_add_popup(request):
    if request.method == 'POST':
        form = ReasonForm(request.POST)
        if form.is_valid():
            reason = form.save(commit=False)
            reason.save()
            reason.logger(str(request.user), " REASON_ADD_POPUP_EXECUTED")
            messages.success(request, 'Reason added')
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')
    else:
        form = ReasonForm()
        debug_logger(str(request.user), " REASON_ADD_POPUP_ENTERED")
    return render(request, 'dfirtrack_main/reason/reasons_add_popup.html',
                  {'form': form})