From f845b310778e693cc85ca763bb1f9a6b892acbc4 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 24 Oct 2020 16:50:16 +0100 Subject: person contact history now filters out private events but the code needs refactoring badly --- ctrack/organisations/views.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ctrack/organisations/views.py') diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index 52d226a..51c8810 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -33,10 +33,20 @@ def person_contact_history(request, person_id): "-date" ) person = get_object_or_404(Person, id=person_id) + + _sdes = [ + filter_private_events( + person.get_single_datetime_events(), request.user + ) + ] + _all = list(itertools.chain.from_iterable(_sdes)) + _all = set(_all) + flat_sdes = sorted(_all, key=lambda e: e.date, reverse=True) + return render( request, "organisations/contact_history.html", - {"events": events, "person": person}, + {"events": flat_sdes, "person": person}, ) @@ -125,7 +135,6 @@ class OrganisationDetailView(PermissionRequiredMixin, DetailView): cafs = org.caf_set.all() # simple datetime events for org - # TODO - a note is not getting registered on org detail page after renamed datetime field so fix! notes = NoteEvent.objects.filter( user=self.request.user, organisation=self.object ).order_by("-created_date") -- cgit v1.2.3