From 1c7d45e92f83263a202d2f72c9daac61d34619cd Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 16 Oct 2024 17:23:14 +0100 Subject: wip: create assessment form --- engagements/views.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'engagements/views.py') diff --git a/engagements/views.py b/engagements/views.py index 7146b67..55ddecd 100644 --- a/engagements/views.py +++ b/engagements/views.py @@ -1,7 +1,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Q -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect, render from django.template.loader import render_to_string from django.urls import reverse_lazy @@ -16,6 +16,7 @@ from .forms import ( EngagementEffortReportingCreateForm, EngagementEffortTravelCreateForm, EngagementStrategyCreateForm, + AssessmentCreateForm, ) from .models import Engagement, EngagementEffort, EngagementStrategy, EngagementType, Organisation from .utils import duration_formatter @@ -209,3 +210,24 @@ class CreateEngagementStrategy(LoginRequiredMixin, CreateView): class OrgListView(LoginRequiredMixin, ListView): model = Organisation + + +@login_required +def create_assessment(request): + if request.method == "POST": + pass + 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() + return render( + request, + "engagements/eng_forms/assessment_create.html", + {"form": form}, + ) -- cgit v1.2.3