diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-04-04 17:12:02 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-04-04 17:12:02 +0100 |
commit | 48ea55b603b44f1a4ad0a7ec9f1aeadfa9015b8b (patch) | |
tree | d6cb9b938c118d608f8d1b4e1d1b9ee5f4329f5e /ctrack/caf | |
parent | 3591b1b87793a2734718390691bdde41af1f8bd0 (diff) |
partially completed the CAF score detail table
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/templates/caf/caf_detail.html | 32 | ||||
-rw-r--r-- | ctrack/caf/urls.py | 4 | ||||
-rw-r--r-- | ctrack/caf/views.py | 24 |
3 files changed, 56 insertions, 4 deletions
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 @@ </div> </div> + <div class="row"> + <div class="col-sm-12 p-2"> + <div class="card bg-light"> + <div class="card-body"> + <div class="card-title text-muted">Assessments</div> + <div class="card-text"> + <div class="table-responsive"> + <table class="table"> + {% for ass in assessments_and_scores %} + <tr> + <th>Assessment</th> + <th></th> + <th>{{ ass.0 }}</th> + <th></th> + </tr> + {% for score in ass.1 %} + <tr> + <td>{{ score.caf_contributing_outcome.designation }}</td> + <td>{{ score.caf_contributing_outcome.name }}</td> + <td>{{ score.caf_contributing_outcome.description }}</td> + <td>{{ score.assessment_score }}</td> + </tr> + {% endfor %} + {% endfor %} + </table> + </div> + </div> + </div> + </div> + </div> + </div> + {% 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("<int:pk>", DetailCAF.as_view(), name="detail") + path("<int:pk>", 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): |