aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/assessments/models.py3
-rw-r--r--ctrack/caf/templates/caf/caf_detail.html32
-rw-r--r--ctrack/caf/urls.py4
-rw-r--r--ctrack/caf/views.py24
4 files changed, 59 insertions, 4 deletions
diff --git a/ctrack/assessments/models.py b/ctrack/assessments/models.py
index ab57fd5..db8c8e1 100644
--- a/ctrack/assessments/models.py
+++ b/ctrack/assessments/models.py
@@ -15,6 +15,9 @@ class CAFAssessment(models.Model):
class Meta:
verbose_name = "CAF Assessment"
+ def get_title(self):
+ return f"CAF Assessment for {self.caf.applicable_systems.first().organisation.name} - version {self.caf.version}"
+
def __str__(self):
return f"CAF Assessment for {self.caf.applicable_systems.first().organisation.name} - version {self.caf.version}"
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):