diff --git a/aleksis/apps/alsijil/tasks.py b/aleksis/apps/alsijil/tasks.py index 72fc90353d9934d2d4c5b307b2cec1fad03c14ef..70bf2ab45856e9abf13d67c56c6d32eb43808ed9 100644 --- a/aleksis/apps/alsijil/tasks.py +++ b/aleksis/apps/alsijil/tasks.py @@ -14,6 +14,8 @@ from aleksis.core.models import Group, PDFFile from aleksis.core.util.celery_progress import ProgressRecorder, recorded_task from aleksis.core.util.pdf import generate_pdf_from_template +from aleksis.apps.cursus.models import Course + from .models import ExtraMark @@ -152,6 +154,26 @@ def generate_full_register_printout( person.filtered_notes = sorted_personal_notes["person"].get(person.pk, []) prefetched_persons.append(person) + # NEXT begins here: + + # build the query-set + group = Group.objects.filter(pk=group) + + if include_teachers_and_subjects_table: + group = group.prefetch_related( + "courses", + "courses__subject", + "courses__teachers", + "child_groups", + "child_groups__courses", + "child_groups__courses__subject", + "child_groups__courses__teachers", + ) + + context["group"] = group[0] + + # OLD + context["school_term"] = group.school_term context["persons"] = prefetched_persons context["excuse_types"] = ExcuseType.objects.filter(count_as_absent=True) diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/register_teachers_and_subjects_table.html b/aleksis/apps/alsijil/templates/alsijil/partials/register_teachers_and_subjects_table.html index d3de44993a5b9c3678e226f6d678a532fa8adb1c..d9c3409d7ba4867f1447c4546916ea9d66d2d1c1 100644 --- a/aleksis/apps/alsijil/templates/alsijil/partials/register_teachers_and_subjects_table.html +++ b/aleksis/apps/alsijil/templates/alsijil/partials/register_teachers_and_subjects_table.html @@ -6,24 +6,20 @@ {% endif %} <th>{% trans 'Subject' %}</th> <th>{% trans 'Teacher' %}</th> - <th>{% trans 'Lesson start' %}</th> - <th>{% trans 'Lesson end' %}</th> <th>{% trans 'Per week' %}</th> </tr> </thead> <tbody> {% for group in groups %} - {% for lesson in group.lessons.all %} + {% for course in group.courses.all %} <tr> {% if len(groups) > 1 %} <td>{{ group.name }}</td> {% endif %} - <td>{{ lesson.subject.name }}</td> - <td>{{ lesson.teachers.all|join:', ' }}</td> - <td>{{ lesson.validity.date_start }}</td> - <td>{{ lesson.validity.date_end }}</td> - <td>{{ lesson.lesson_periods.count }}</td> + <td>{{ course.subject.name }}</td> + <td>{{ course.teachers.all|join:', ' }}</td> + <td>{{ course.lesson_quota }}</td> </tr> {% endfor %} {% endfor %} diff --git a/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html b/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html index 5d740a2a31551950b0dc57e29d0163b0c85d6f12..d42aecfa0a35139ebcc94170bbbfc9e6722bfcf9 100644 --- a/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html +++ b/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html @@ -30,14 +30,14 @@ <div class="page-break"> </div> {% if include_teachers_and_subjects_table %} - {% if group.lessons %} + {% if group.courses %} <h4>{% trans 'Teachers and lessons in group' %} {{ group.name }}</h4> {% include "alsijil/partials/register_teachers_and_subjects_table.html" with groups=[group] only %} <div class="page-break"> </div> {% endif %} - {% if child_groups %} + {% if group.child_groups %} <h4>{% trans 'Teachers and lessons in child groups' %}</h4> - {% include "alsijil/partials/register_teachers_and_subjects_table.html" with groups=child_groups only} + {% include "alsijil/partials/register_teachers_and_subjects_table.html" with groups=group.child_groups only} <div class="page-break"> </div> {% endif %} {% endif %}