From 48ea55b603b44f1a4ad0a7ec9f1aeadfa9015b8b Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 4 Apr 2020 17:12:02 +0100 Subject: partially completed the CAF score detail table --- ctrack/caf/templates/caf/caf_detail.html | 32 ++++++++++++++++++++++++++++++++ ctrack/caf/urls.py | 4 ++-- ctrack/caf/views.py | 24 ++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) (limited to 'ctrack/caf') diff --git a/ctrack/caf/templates/caf/caf_detail.html b/ctrack/caf/templates/caf/caf_detail.html index 2cce6d1..7a8c151 100644 --- a/ctrack/caf/templates/caf/caf_detail.html +++ b/ctrack/caf/templates/caf/caf_detail.html @@ -59,6 +59,38 @@ +
+
+
+
+
Assessments
+
+
+ + {% for ass in assessments_and_scores %} + + + + + + + {% for score in ass.1 %} + + + + + + + {% endfor %} + {% endfor %} +
Assessment{{ ass.0 }}
{{ score.caf_contributing_outcome.designation }}{{ score.caf_contributing_outcome.name }}{{ score.caf_contributing_outcome.description }}{{ score.assessment_score }}
+
+
+
+
+
+
+ {% endblock %} diff --git a/ctrack/caf/urls.py b/ctrack/caf/urls.py index dc228ae..dc5bc44 100644 --- a/ctrack/caf/urls.py +++ b/ctrack/caf/urls.py @@ -1,7 +1,7 @@ from django.urls import path from django.views.decorators.cache import cache_page -from ctrack.caf.views import CreateCAF, ListCAF, ListApplicableSystem, DetailCAF +from ctrack.caf.views import CreateCAF, ListCAF, ListApplicableSystem, caf_detail_view app_name = "caf" @@ -9,5 +9,5 @@ urlpatterns = [ path("", view=CreateCAF.as_view(), name="create"), path("", view=ListCAF.as_view(), name="caf_list"), path("applicablesystems", cache_page(60 * 60)(ListApplicableSystem.as_view()), name="es_list"), - path("", DetailCAF.as_view(), name="detail") + path("", caf_detail_view, name="detail") ] diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index c2c3047..d6fcdf1 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -1,6 +1,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin +from django.shortcuts import render from django.views.generic import CreateView, ListView, DetailView +from ctrack.assessments.models import CAFAssessment, CAFObjective, CAFPrinciple, CAFAssessmentOutcomeScore from ctrack.caf.forms import CAFForm from ctrack.caf.models import ApplicableSystem, CAF @@ -19,8 +21,26 @@ class ListCAF(LoginRequiredMixin, ListView): pass -class DetailCAF(LoginRequiredMixin, DetailView): - model = CAF +# class DetailCAF(LoginRequiredMixin, DetailView): +# model = CAF + +# Let's write a traditional function view! +def caf_detail_view(request, pk): + caf = CAF.objects.get(pk=pk) + # get any assessments that have been done on this caf + assessments = caf.cafassessment_set.all() + caf_principles = CAFPrinciple.objects.all() + _scrs = [] + for ass in assessments: + lst_scores = [] + lst_scores.append(ass.get_title()) + lst_scores.append(CAFAssessmentOutcomeScore.objects.filter(caf_assessment=ass)) + _scrs.append(lst_scores) + context = { + 'object': caf, + 'assessments_and_scores': _scrs + } + return render(request, 'caf/caf_detail.html', context) class ListApplicableSystem(LoginRequiredMixin, ListView): -- cgit v1.2.3