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

[Full register] Get lessons and child groups in view and prefetch data there

parent 0e4454bf
No related branches found
No related tags found
1 merge request!90Performance optimizations
......@@ -175,7 +175,7 @@
</thead>
<tbody>
{% for lesson in group.lessons.all %}
{% for lesson in lessons %}
<tr>
<td>{{ lesson.subject.name }}</td>
<td>{{ lesson.teachers.all|join:', ' }}</td>
......@@ -206,7 +206,7 @@
</thead>
<tbody>
{% for child_group in group.child_groups.all %}
{% for child_group in child_groups %}
{% for lesson in child_group.lessons.all %}
<tr>
<td>{{ child_group.name }}</td>
......
......@@ -471,7 +471,18 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
context["periods_by_day"] = periods_by_day
context["lesson_periods"] = lesson_periods
context["today"] = date.today()
context["lessons"] = (
group.lessons.all()
.select_related("validity", "subject")
.prefetch_related("teachers", "lesson_periods")
)
context["child_groups"] = group.child_groups.all().prefetch_related(
"lessons",
"lessons__validity",
"lessons__subject",
"lessons__teachers",
"lessons__lesson_periods",
)
return render(request, "alsijil/print/full_register.html", context)
......
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