def contacts_add_popup(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): contact = form.save(commit=False) contact.save() contact.logger(str(request.user), " CONTACT_ADD_POPUP_EXECUTED") messages.success(request, 'Contact added') return HttpResponse('<script type="text/javascript">window.close();</script>') else: form = ContactForm() debug_logger(str(request.user), " CONTACT_ADD_POPUP_ENTERED") return render(request, 'dfirtrack_main/contact/contacts_add_popup.html', {'form': form})
def contacts_add(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): contact = form.save(commit=False) contact.save() contact.logger(str(request.user), " CONTACT_ADD_EXECUTED") messages.success(request, 'Contact added') return redirect('/contacts') else: form = ContactForm() debug_logger(str(request.user), " CONTACT_ADD_ENTERED") return render(request, 'dfirtrack_main/contact/contacts_add.html', {'form': form})
def contacts_edit(request, pk): contact = get_object_or_404(Contact, pk=pk) if request.method == 'POST': form = ContactForm(request.POST, instance=contact) if form.is_valid(): contact = form.save(commit=False) contact.save() contact.logger(str(request.user), " CONTACT_EDIT_EXECUTED") messages.success(request, 'Contact edited') return redirect('/contacts') else: form = ContactForm(instance=contact) contact.logger(str(request.user), " CONTACT_EDIT_ENTERED") return render(request, 'dfirtrack_main/contact/contacts_edit.html', {'form': form})