diff --git a/aleksis/apps/alsijil/tasks.py b/aleksis/apps/alsijil/tasks.py index b55d200b5c01538428574e70c96dd82352dbbd8e..da691ac24f5f8084c0cea6226c464386ace835bd 100644 --- a/aleksis/apps/alsijil/tasks.py +++ b/aleksis/apps/alsijil/tasks.py @@ -157,7 +157,7 @@ def generate_full_register_printout( prefetched_persons.append(person) # NEXT begins here: - def prefetch_notable_participations(*prefetch_related): + def prefetch_notable_participations(select_related=[], prefetch_related=[]): return Prefetch( "participations", to_attr="notable_participations", @@ -166,18 +166,18 @@ def generate_full_register_printout( Q(absence_reason__isnull=True) | Q(tardiness__isnull=True) ) - .select_related("absence_reason") + .select_related("absence_reason", *select_related) .prefetch_related(*prefetch_related), ) - def prefetch_personal_notes(name, *prefetch_related): + def prefetch_personal_notes(name, select_related=[], prefetch_related=[]): return Prefetch( name, queryset=NewPersonalNote.objects .exclude( Q(note="") | Q(extra_mark=None)) - .select_related("extra_mark") + .select_related("extra_mark", *select_related) .prefetch_related(*prefetch_related), ) @@ -222,17 +222,21 @@ def generate_full_register_printout( doc_query_set = Documentation.objects.select_related("subject").prefetch_related("teachers"), context["members"] = context["members"].prefetch_related( prefetch_notable_participations( - Prefetch( - "related_documentation", - queryset=doc_query_set, - ) + prefetch_related=[ + Prefetch( + "related_documentation", + queryset=doc_query_set, + ) + ], ), prefetch_personal_notes( "new_personal_notes", - Prefetch( - "documentation", - queryset=doc_query_set, - ) + prefetch_related=[ + Prefetch( + "documentation", + queryset=doc_query_set, + ) + ], ), )