def cases_add(request): if request.method == 'POST': form = CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_ADD_EXECUTED") messages.success(request, 'Case added') return redirect('/cases')
if request.method == 'POST': form = CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_ADD_EXECUTED") messages.success(request, 'Case added') return redirect('/cases') else: form = CaseForm() debug_logger(str(request.user), " CASES_ADD_ENTERED") return render(request, 'dfirtrack_main/case/cases_add.html', {'form': form}) @login_required(login_url="/login") def cases_edit(request, pk): case = get_object_or_404(Case, pk=pk) if request.method == 'POST': form = CaseForm(request.POST, instance=case) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_EDIT_EXECUTED") messages.success(request, 'Case edited') return redirect('/cases') else: form = CaseForm(instance=case) case.logger(str(request.user), " CASES_EDIT_ENTERED") return render(request, 'dfirtrack_main/case/cases_edit.html', {'form': form})