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

Adapt the register_teachers_and_subjects_table to the new datamodel

parent fbbc2e79
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
...@@ -14,6 +14,8 @@ from aleksis.core.models import Group, PDFFile ...@@ -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.celery_progress import ProgressRecorder, recorded_task
from aleksis.core.util.pdf import generate_pdf_from_template from aleksis.core.util.pdf import generate_pdf_from_template
from aleksis.apps.cursus.models import Course
from .models import ExtraMark from .models import ExtraMark
...@@ -152,6 +154,26 @@ def generate_full_register_printout( ...@@ -152,6 +154,26 @@ def generate_full_register_printout(
person.filtered_notes = sorted_personal_notes["person"].get(person.pk, []) person.filtered_notes = sorted_personal_notes["person"].get(person.pk, [])
prefetched_persons.append(person) 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["school_term"] = group.school_term
context["persons"] = prefetched_persons context["persons"] = prefetched_persons
context["excuse_types"] = ExcuseType.objects.filter(count_as_absent=True) context["excuse_types"] = ExcuseType.objects.filter(count_as_absent=True)
......
...@@ -6,24 +6,20 @@ ...@@ -6,24 +6,20 @@
{% endif %} {% endif %}
<th>{% trans 'Subject' %}</th> <th>{% trans 'Subject' %}</th>
<th>{% trans 'Teacher' %}</th> <th>{% trans 'Teacher' %}</th>
<th>{% trans 'Lesson start' %}</th>
<th>{% trans 'Lesson end' %}</th>
<th>{% trans 'Per week' %}</th> <th>{% trans 'Per week' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for group in groups %} {% for group in groups %}
{% for lesson in group.lessons.all %} {% for course in group.courses.all %}
<tr> <tr>
{% if len(groups) > 1 %} {% if len(groups) > 1 %}
<td>{{ group.name }}</td> <td>{{ group.name }}</td>
{% endif %} {% endif %}
<td>{{ lesson.subject.name }}</td> <td>{{ course.subject.name }}</td>
<td>{{ lesson.teachers.all|join:', ' }}</td> <td>{{ course.teachers.all|join:', ' }}</td>
<td>{{ lesson.validity.date_start }}</td> <td>{{ course.lesson_quota }}</td>
<td>{{ lesson.validity.date_end }}</td>
<td>{{ lesson.lesson_periods.count }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
......
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
<div class="page-break">&nbsp;</div> <div class="page-break">&nbsp;</div>
{% if include_teachers_and_subjects_table %} {% if include_teachers_and_subjects_table %}
{% if group.lessons %} {% if group.courses %}
<h4>{% trans 'Teachers and lessons in group' %} {{ group.name }}</h4> <h4>{% trans 'Teachers and lessons in group' %} {{ group.name }}</h4>
{% include "alsijil/partials/register_teachers_and_subjects_table.html" with groups=[group] only %} {% include "alsijil/partials/register_teachers_and_subjects_table.html" with groups=[group] only %}
<div class="page-break">&nbsp;</div> <div class="page-break">&nbsp;</div>
{% endif %} {% endif %}
{% if child_groups %} {% if group.child_groups %}
<h4>{% trans 'Teachers and lessons in child groups' %}</h4> <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">&nbsp;</div> <div class="page-break">&nbsp;</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
......
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