diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index 4d2487e0ccf091c07040084401e442dcd7684b30..9e2d50dead158fcf5f408ffdff59327cda942a01 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -155,7 +155,12 @@ class Documentation(CalendarEvent): amends__in=[e["REFERENCE_OBJECT"] for e in events], ) .prefetch_related( - "participations", "teachers", "personal_notes", "personal_notes__extra_mark" + "participations", + "participations__person", + "participations__absence_reason", + "teachers", + "personal_notes", + "personal_notes__extra_mark", ) .select_related("course", "subject") ) diff --git a/aleksis/apps/alsijil/schema/documentation.py b/aleksis/apps/alsijil/schema/documentation.py index 93e844c5642eed9e987f32366dfb2f02e69d6346..6b0c3e1ffb0c7a328eadb159c9407c5f8a2d74fa 100644 --- a/aleksis/apps/alsijil/schema/documentation.py +++ b/aleksis/apps/alsijil/schema/documentation.py @@ -1,6 +1,7 @@ from django.core.exceptions import PermissionDenied import graphene +from graphene_django import bypass_get_queryset from graphene_django.types import DjangoObjectType from reversion import create_revision, set_comment, set_user @@ -61,12 +62,14 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp old_id = graphene.ID(required=False) @staticmethod + @bypass_get_queryset def resolve_amends(root: Documentation, info, **kwargs): if hasattr(root, "_amends_prefetched"): return root._amends_prefetched return root.amends @staticmethod + @bypass_get_queryset def resolve_teachers(root: Documentation, info, **kwargs): if not str(root.pk).startswith("DUMMY") and hasattr(root, "teachers"): return root.teachers @@ -105,6 +108,7 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp ) @staticmethod + @bypass_get_queryset def resolve_participations(root: Documentation, info, **kwargs): # A dummy documentation will not have any participations if str(root.pk).startswith("DUMMY") or not hasattr(root, "participations"):