Skip to content
Snippets Groups Projects
Verified Commit 8d501e18 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use prefetched amends and prevent resolving by optimizer

This would problematic due to django-polymorphic.
parent f24a99fa
No related branches found
No related tags found
1 merge request!429Resolve "Adapt to active school term"
Pipeline #193895 failed
......@@ -182,6 +182,7 @@ class Documentation(CalendarEvent):
)
):
continue
doc._amends_prefetched = event_reference_obj
docs.append(doc)
elif not absences_exist:
if event_reference_obj.amends:
......
......@@ -32,7 +32,6 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp
fields = (
"id",
"course",
"amends",
"subject",
"topic",
"homework",
......@@ -61,6 +60,12 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp
old_id = graphene.ID(required=False)
@staticmethod
def resolve_amends(root: Documentation, info, **kwargs):
if hasattr(root, "_amends_prefetched"):
return root._amends_prefetched
return root.amends
@staticmethod
def resolve_teachers(root: Documentation, info, **kwargs):
if not str(root.pk).startswith("DUMMY") and hasattr(root, "teachers"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment