aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-19 16:32:21 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-19 16:32:51 +0100
commitd8a07a2157c627c51a5dce963a92be87baf7c31d (patch)
treef94d23f9b4eb38cc7f374ba7e1d0dc38882e0645
parent9cc3de6d0245bdc4ed87b810a2208efdd09b6277 (diff)
list of single_datetime_events on org detail page now sorted by date
-rw-r--r--ctrack/organisations/views.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 81af8d4..b688fea 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -1,20 +1,18 @@
import itertools
from typing import Any
-from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
+from django.contrib.auth.mixins import PermissionRequiredMixin
from django.db import transaction
-from django.db.models import Q, QuerySet
+from django.db.models import Q
from django.http import HttpResponseRedirect
-from django.shortcuts import render, get_object_or_404
+from django.shortcuts import get_object_or_404, render
from django.urls import reverse, reverse_lazy
from django.views.generic import CreateView, DetailView, FormView, ListView
-from ctrack.caf.models import EssentialService, CAF
+from ctrack.caf.models import CAF, EssentialService
from ctrack.register.models import EngagementEvent
from .forms import AddressInlineFormSet, IncidentReportForm, OrganisationCreateForm
from .models import IncidentReport, Organisation, Person
-
-
# TODO - needs a permission on this view
from .utils import filter_private_events
@@ -96,7 +94,11 @@ class OrganisationDetailView(PermissionRequiredMixin, DetailView):
)
for person in peoples
]
- flat_sdes = list(itertools.chain.from_iterable(_sdes))
+ flat_sdes = sorted(
+ list(itertools.chain.from_iterable(_sdes)),
+ key=lambda e: e.datetime,
+ reverse=True,
+ )
# 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...