diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-19 16:21:03 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-19 16:25:09 +0100 |
commit | 9cc3de6d0245bdc4ed87b810a2208efdd09b6277 (patch) | |
tree | 2987cca4ef6eb58fa2e6817c40fb920707f167b4 /ctrack/organisations/views.py | |
parent | bb39f7f52d5ff6dcf311d9e2a987417796e09424 (diff) |
can now filter out private events not belonging to logged in user
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/views.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index e8affdb..81af8d4 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -16,6 +16,9 @@ from .models import IncidentReport, Organisation, Person # TODO - needs a permission on this view +from .utils import filter_private_events + + def essential_service_detail(request, pk): es = EssentialService.objects.get(pk=pk) org = es.organisation @@ -87,12 +90,19 @@ class OrganisationDetailView(PermissionRequiredMixin, DetailView): cafs = org.caf_set.all() # simple datetime events for org - _sdes = [person.get_single_datetime_events() for person in peoples] + _sdes = [ + filter_private_events( + person.get_single_datetime_events(), self.request.user + ) + for person in peoples + ] flat_sdes = list(itertools.chain.from_iterable(_sdes)) # 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") + 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() |