aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/views.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-02 14:06:22 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-02 14:06:22 +0100
commita38fce358643f5f8e1b2d7ec8e17342f760e16d4 (patch)
tree768c80bf2a9df477cc17227f2ae813b44c1f3c52 /ctrack/organisations/views.py
parent844804083d74731c6f275b25f01e6085271edc9e (diff)
Now lists basic CAF events on CAF detail page
Diffstat (limited to 'ctrack/organisations/views.py')
-rw-r--r--ctrack/organisations/views.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 9658abf..c56c106 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -2,6 +2,7 @@ from typing import Any
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
from django.db import transaction
+from django.db.models import Q
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.urls import reverse, reverse_lazy
@@ -83,8 +84,12 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail
org = kwargs["object"]
peoples = org.person_set.all()
cafs = org.caf_set.all()
- engagement_events = EngagementEvent.objects.filter(participants__in=peoples).order_by("-date")
+
+ # Some events will not involve a participant, which is what ties an event to an organisation.
+ # Because we want to list events to an organisation here we must related it via the CAF object too...
+ engagement_events = EngagementEvent.objects.filter(Q(participants__in=peoples) | Q(related_caf__in=cafs)).order_by("-date")
essential_services = EssentialService.objects.filter(organisation=org)
+
no_addr = org.addresses.count()
if no_addr > 1:
context["no_addr"] = no_addr