Skip to content
Snippets Groups Projects
Commit 8d89bf54 authored by permcu's avatar permcu
Browse files

Fix annotate_person_statistics_from_documentations

parent c3f5cf28
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
......@@ -93,9 +93,12 @@ def annotate_person_statistics(
return persons
def annotate_person_statistics_from_documentations(docs: QuerySet[Documentation]) -> QuerySet[Person]:
def annotate_person_statistics_from_documentations(
persons: QuerySet[Person],
docs: QuerySet[Documentation]
) -> QuerySet[Person]:
"""Annotate a queryset of persons with class register statistics from queryset of documentations."""
docs = list(documentations.values_list("pk", flat=True))
docs = list(docs.values_list("pk", flat=True))
return annotate_person_statistics(
persons,
Q(participations__related_documentation__in=docs),
......@@ -113,4 +116,4 @@ def annotate_person_statistics_for_school_term(
)
if group:
documentations.filter(Q(course__groups=group) | Q(course__groups__parent_groups=group))
return annotate_person_statistics_from_documentations(documentations)
return annotate_person_statistics_from_documentations(persons, documentations)
......@@ -98,7 +98,7 @@ def generate_full_register_printout(
)
if include_members_table or include_person_overviews:
context["members"] = annotate_person_statistics_from_documentations(documentations)
context["members"] = annotate_person_statistics_from_documentations(group.members.all(), documentations)
if include_person_overviews:
doc_query_set = Documentation.objects.select_related("subject").prefetch_related("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