From 788cb0ae7ee5353b7b57623449fa10996e5839f9 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 23 Oct 2024 16:24:13 +0100 Subject: Rudimentary form to create Assessment from org EP page --- engagements/views.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'engagements/views.py') diff --git a/engagements/views.py b/engagements/views.py index 55ddecd..2e40af8 100644 --- a/engagements/views.py +++ b/engagements/views.py @@ -213,21 +213,17 @@ class OrgListView(LoginRequiredMixin, ListView): @login_required -def create_assessment(request): +def create_assessment(request, org): if request.method == "POST": - pass + form = AssessmentCreateForm(request.POST, org=org) + if form.is_valid(): + form.save() + return redirect("engagements:home") else: - eng_type_id = request.GET.get("eng_type_id", None) - entity_id = request.GET.get("entity_id", None) - if not eng_type_id: - return HttpResponseBadRequest("You must provide an engagement_type id") - if not entity_id: - return HttpResponseBadRequest("You must provide an entity id") - eng_type = EngagementType.objects.get(id=eng_type_id) - entity = Organisation.objects.get(id=entity_id) - form = AssessmentCreateForm() + form = AssessmentCreateForm(org=org) + org = Organisation.objects.get(slug=org) return render( request, "engagements/eng_forms/assessment_create.html", - {"form": form}, + {"form": form, "org": org}, ) -- cgit v1.2.3