def reportitems_edit(request, pk): reportitem = get_object_or_404(Reportitem, pk=pk) if request.method == 'POST': form = ReportitemForm(request.POST, instance=reportitem) if form.is_valid(): reportitem = form.save(commit=False) reportitem.reportitem_modified_by_user_id = request.user reportitem.save() reportitem.logger(str(request.user), " REPORTITEM_EDIT_EXECUTED") messages.success(request, 'Reportitem edited') return redirect('/systems/' + str(reportitem.system.system_id)) else: form = ReportitemForm(instance=reportitem) reportitem.logger(str(request.user), " REPORTITEM_EDIT_ENTERED") return render(request, 'dfirtrack_main/reportitem/reportitems_edit.html', {'form': form})
def reportitems_add(request): if request.method == 'POST': form = ReportitemForm(request.POST) if form.is_valid(): reportitem = form.save(commit=False) reportitem.reportitem_created_by_user_id = request.user reportitem.reportitem_modified_by_user_id = request.user reportitem.save() reportitem.logger(str(request.user), " REPORTITEM_ADD_EXECUTED") messages.success(request, 'Reportitem added') return redirect('/systems/' + str(reportitem.system.system_id)) else: if request.method == 'GET' and 'system' in request.GET: system = request.GET['system'] form = ReportitemForm(initial={ 'system': system, }) else: form = ReportitemForm() debug_logger(str(request.user), " REPORTITEM_ADD_ENTERED") return render(request, 'dfirtrack_main/reportitem/reportitems_add.html', {'form': form})