diff --git a/aleksis/apps/chronos/managers.py b/aleksis/apps/chronos/managers.py index 2fb3c8e36ce5242fc96425e28b1c393c4df7865b..6611551541ee08bdab84e1adb9497401a094055b 100644 --- a/aleksis/apps/chronos/managers.py +++ b/aleksis/apps/chronos/managers.py @@ -885,14 +885,14 @@ class LessonEventQuerySet(RecurrencePolymorphicQuerySet): def for_participant(self, person: Union[int, Person]) -> "LessonEventQuerySet": """Get all lesson events the person participates in (including amends).""" - amended = self.filter(Q(amended_by__isnull=False) | Q(groups__members=person)).values_list( + amended = self.filter(Q(amended_by__isnull=False) & Q(groups__members=person)).values_list( "amended_by__pk", flat=True ) return self.filter(Q(groups__members=person) | Q(pk__in=amended)).distinct() def for_owner(self, person: Union[int, Person]) -> "LessonEventQuerySet": """Get all lesson events the person owns any group of (including amends).""" - amended = self.filter(Q(amended_by__isnull=False) | Q(groups__owners=person)).values_list( + amended = self.filter(Q(amended_by__isnull=False) & Q(groups__owners=person)).values_list( "amended_by__pk", flat=True ) return self.filter(Q(groups__owners=person) | Q(pk__in=amended)).distinct()