Skip to content
Snippets Groups Projects
Commit 9b3362c4 authored by permcu's avatar permcu
Browse files

WIP Adapt the coursebook-printout to the new datamodel

parent aee8c0bd
No related branches found
No related tags found
No related merge requests found
Pipeline #193390 failed
This commit is part of merge request !422. Comments created here will be created in the context of that merge request.
......@@ -93,6 +93,16 @@ def annotate_person_statistics(
return persons
def annotate_person_statistics_from_documentations(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))
return annotate_person_statistics(
persons,
Q(participations__related_documentation__in=docs),
Q(new_personal_notes__documentation__in=docs),
)
def annotate_person_statistics_for_school_term(
persons: QuerySet[Person], school_term: SchoolTerm, group: Group | None = None
) -> QuerySet[Person]:
......@@ -103,9 +113,4 @@ def annotate_person_statistics_for_school_term(
)
if group:
documentations.filter(Q(course__groups=group) | Q(course__groups__parent_groups=group))
docs = list(documentations.values_list("pk", flat=True))
return annotate_person_statistics(
persons,
Q(participations__related_documentation__in=docs),
Q(new_personal_notes__documentation__in=docs),
)
return annotate_person_statistics_from_documentations(documentations)
......@@ -185,8 +185,15 @@ def generate_full_register_printout(
group = group[0]
context["group"] = group
if include_members_table or include_person_overviews or include_coursebook:
context["documentations"] = Documentation.objects.filter(
Q(datetime_start__date__gte=group.school_term.date_start)
& Q(datetime_end__date__lte=group.school_term.date_end)
& (Q(course__groups=group) | Q(course__groups__parent_groups=group))
)
if include_members_table or include_person_overviews:
context["members"] = annotate_person_statistics_for_school_term(group.members.all(), group.school_term, group)
context["members"] = annotate_person_statistics_from_documentations(context["documentations"])
if include_person_overviews:
doc_query_set = Documentation.objects.select_related("subject").prefetch_related("teachers"),
......@@ -223,6 +230,13 @@ def generate_full_register_printout(
),
)
if include_coursebook:
context["documentations"] = context["documentations"]
# use dates to get list of days
# use them as keys & give docs for days
# then use this
# OLD
context["school_term"] = group.school_term
......
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