diff --git a/aleksis/apps/chronos/managers.py b/aleksis/apps/chronos/managers.py index ce1670f53f79bd21e71b59eb260603825edf0f57..2ba38ff0711f341a242785bf3e9521f470d6d3d3 100644 --- a/aleksis/apps/chronos/managers.py +++ b/aleksis/apps/chronos/managers.py @@ -878,7 +878,7 @@ class LessonEventQuerySet(PolymorphicQuerySet): 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() diff --git a/aleksis/apps/chronos/models.py b/aleksis/apps/chronos/models.py index 9533ce1b0c83519f4b6d3936235e660f0f706e07..732c95d53a22ecdb3764b4f71bf55a5b3aa6e410 100644 --- a/aleksis/apps/chronos/models.py +++ b/aleksis/apps/chronos/models.py @@ -1533,7 +1533,7 @@ class LessonEvent(CalendarEvent): .get_objects(request, params) .not_instance_of(SupervisionEvent) .select_related("subject", "course") - .prefetch_related("groups", "teachers", "rooms") + .prefetch_related("groups", "teachers", "rooms", "groups__members") ) if request and not has_person(request.user):