From 537370e45631a7fa35ac855e746771ce6ca9224a Mon Sep 17 00:00:00 2001 From: MR Lemon Date: Thu, 16 Apr 2020 16:38:52 +0100 Subject: started to make a fist of the CAF list page --- ctrack/caf/models.py | 13 +++++++++++-- ctrack/caf/views.py | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'ctrack/caf') diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 78ebda7..5d7b5b0 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -79,11 +79,20 @@ class CAF(models.Model): class Meta: verbose_name = "CAF" - + def get_absolute_url(self): return reverse("caf:detail", kwargs={"pk": self.pk}) - + def applicable_systems(self): + """ + Returns a Queryset of objects we can use in our templates. + """ + return ApplicableSystem.objects.filter(caf=self) + + def organisation(self): + first_ass = ApplicableSystem.objects.filter(caf=self).first() + return first_ass.organisation + def __str__(self): # Get the organisation and applicable system ass = ApplicableSystem.objects.filter(caf=self).first() diff --git a/ctrack/caf/views.py b/ctrack/caf/views.py index c33b2d1..f9d794e 100644 --- a/ctrack/caf/views.py +++ b/ctrack/caf/views.py @@ -6,12 +6,12 @@ from ctrack.assessments.models import CAFAssessment, CAFObjective, CAFPrinciple, from ctrack.caf.models import ApplicableSystem, CAF -# class ListCAF(LoginRequiredMixin, ListView): -# model = CAF -# paginate_by = 20 +class ListCAF(LoginRequiredMixin, ListView): + model = CAF + + def get_context_data(self, **kwargs): + return super().get_context_data(**kwargs) -# def get_context_data(self, **kwargs): -# return super().get_context_data(**kwargs) # Let's write a traditional function view! def caf_detail_view(request, pk): -- cgit v1.2.3