aboutsummaryrefslogblamecommitdiffstats
path: root/ctrack/organisations/utils.py
blob: 121a6946a1354185865ace3354fb0cd8b7c5574b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                    
from django.contrib.auth.models import User
from django.db.models import QuerySet, Q


def filter_private_events(events: QuerySet, user: User):
    """
    Given a QuerySet containing SingleDateTimeEvent objects,
    ensure that any objects whose user==user and private==True
    are filtered out. This supports OrganisationDetailView, which
    lists all events for an organisation but which must hide private
    events for the logged-in user.
    """
    return events.exclude(~Q(user=user) & Q(private=True))