From 37a5818eb76ad75055807d300d1cdd6fb5821b0a Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 1 Jun 2020 16:32:03 +0100 Subject: engagement events now appear on org page --- .../templates/organisations/organisation_detail.html | 12 ++++-------- ctrack/organisations/views.py | 7 ++++++- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'ctrack/organisations') diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html index 29d188c..bf16c87 100644 --- a/ctrack/organisations/templates/organisations/organisation_detail.html +++ b/ctrack/organisations/templates/organisations/organisation_detail.html @@ -99,23 +99,19 @@
-
OES EngagementsAdd +
{% if engagement_events|length > 0 %} {% for event in engagement_events %} - - + + {% endfor %} {% else %} - Add + Add new... {% endif %}
{{ ass.name }}{{ ass.description }}
- - {{ ass.caf }} - | Edit System -
{{ event.type}}{{ event.short_description }}
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index 0dfe21d..394966a 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -6,6 +6,8 @@ from django.http import HttpResponseRedirect from django.urls import reverse, reverse_lazy from django.views.generic import CreateView, DetailView, FormView, ListView +from ctrack.register.models import EngagementEvent + from .forms import AddressInlineFormSet, IncidentReportForm, OrganisationCreateForm from .models import IncidentReport, Organisation, Person @@ -59,9 +61,11 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail model = Organisation permission_required = "organisations.view_organisation" - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: + def get_context_data(self, **kwargs: Any): context = super().get_context_data() org = kwargs["object"] + peoples = org.person_set.all() + engagement_events = EngagementEvent.objects.filter(participants__in=peoples) no_addr = org.addresses.count() if no_addr > 1: context["no_addr"] = no_addr @@ -75,6 +79,7 @@ class OrganisationDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detail context["people"] = people applicable_systems = org.applicablesystem_set.all() context["applicable_systems"] = applicable_systems + context["engagement_events"] = engagement_events return context -- cgit v1.2.3