From 5d5f3f3626816aeb23778c79bd5a6c15b43aa810 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 23 Oct 2020 15:31:03 +0100 Subject: fixed the order of events on the org detail page --- ctrack/users/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ctrack/users') diff --git a/ctrack/users/views.py b/ctrack/users/views.py index 8924ea8..8f94d85 100644 --- a/ctrack/users/views.py +++ b/ctrack/users/views.py @@ -35,9 +35,9 @@ class UserDetailView(DetailView): context = super().get_context_data() user = self.request.user lead_oes = Organisation.objects.filter(lead_inspector=user).order_by("name") - _single_date_events = SingleDateTimeEvent.objects.filter(user=user).all() - _caf_single_date_events = CAFSingleDateEvent.objects.all() - _caf_twin_date_events = CAFTwinDateEvent.objects.all() + _single_date_events = SingleDateTimeEvent.objects.filter(user=user).order_by("date") + _caf_single_date_events = CAFSingleDateEvent.objects.order_by("date") + _caf_twin_date_events = CAFTwinDateEvent.objects.order_by("date") _combined = list(itertools.chain(_caf_twin_date_events, _caf_single_date_events, _single_date_events)) all_events = sorted(_combined, key=self._comp_dates, reverse=True) for event in all_events: @@ -46,6 +46,7 @@ class UserDetailView(DetailView): setattr(event, "organisation", org) except AttributeError: setattr(event, "organisation", None) + all_events = sorted(_combined, key=self._comp_dates, reverse=True) context["all_events"] = all_events context["lead_oes"] = lead_oes return context -- cgit v1.2.3