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

Adapt the register_members_table to the new datamodel

& reintroduce some abbreviations.
parent 462b81f7
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
This commit is part of merge request !422. Comments created here will be created in the context of that merge request.
......@@ -18,6 +18,7 @@ from aleksis.apps.cursus.models import Course
from aleksis.apps.kolego.models.absence import AbsenceReason
from .models import ExtraMark
from .model_extensions import annotate_person_statistics_for_school_term
@recorded_task
......@@ -163,11 +164,15 @@ def generate_full_register_printout(
if include_cover:
group = group.select_related("school_term")
if include_abbreviations:
if include_abbreviations or include_members_table:
# TODO: AbsenceReasonTag important?
context["absence_reasons"] = AbsenceReason.objects.all()
context["absence_reasons"] = AbsenceReason.objects.filter(count_as_absent=True)
context["absence_reasons_not_counted"] = AbsenceReason.objects.filter(count_as_absent=False)
context["extra_marks"] = ExtraMark.objects.all()
if include_members_table:
group = group.prefetch_related("members")
if include_teachers_and_subjects_table:
group = group.prefetch_related(
"courses",
......@@ -179,7 +184,11 @@ def generate_full_register_printout(
"child_groups__courses__teachers",
)
context["group"] = group[0]
group = group[0]
context["group"] = group
if include_members_table:
context["members"] = annotate_person_statistics_for_school_term(group.members.all(), group.school_term, group)
# OLD
......
<h4>{% trans "Abbreviations" %}</h4>
<h5>{% trans "General" %}</h5>
<!-- TODO: This implies AbsenceReasons can not have the shortNames a and b! -->
<ul class="collection">
<li class="collection-item">
<strong>(a)</strong> {% trans "Absent" %}
</li>
<li class="collection-item">
<strong>(b)</strong> {% trans "Late" %}
</li>
</ul>
{% if absence_reasons %}
<h5>{% trans "Absence reasons" %}</h5>
<ul class="collection">
{% for absence_reason in absence_reasons %}
{% if absence_reason.count_as_absent %}
<li class="collection-item">
<strong>({{ absence_reason.short_name }})</strong> {{ absence_reason.name }}
</li>
{% endif %}
<li class="collection-item">
<strong>({{ absence_reason.short_name }})</strong> {{ absence_reason.name }}
</li>
{% endfor %}
</ul>
<h5>{% trans "Absence reasons (not counted as absent)" %}</h5>
<ul class="collection">
{% for absence_reason in absence_reasons %}
{% if not absence_reason.count_as_absent %}
<li class="collection-item">
<strong>({{ absence_reason.short_name }})</strong> {{ absence_reason.name }}
</li>
{% endif %}
{% for absence_reason in absence_reasons_not_counted %}
<li class="collection-item">
<strong>({{ absence_reason.short_name }})</strong> {{ absence_reason.name }}
</li>
{% endfor %}
</ul>
{% endif %}
......
......@@ -9,14 +9,11 @@
<th>{% trans 'Sex' %}</th>
<th>{% trans 'Date of birth' %}</th>
<th>{% trans '(a)' %}</th>
<th>{% trans "Sum (e)" %}</th>
<th>{% trans "(e)" %}</th>
{% for excuse_type in excuse_types %}
<th>({{ excuse_type.short_name }})</th>
{% for absence_reason in absence_reasons %}
<th>({{ absence_reason.short_name }})</th>
{% endfor %}
<th>{% trans '(u)' %}</th>
{% for excuse_type in excuse_types_not_absent %}
<th>({{ excuse_type.short_name }})</th>
{% for absence_reason in absence_reasons_not_counted %}
<th>({{ absence_reason.short_name }})</th>
{% endfor %}
<th>{% trans '(b)' %}</th>
{% for extra_mark in extra_marks %}
......@@ -26,24 +23,22 @@
</thead>
<tbody>
{% for person in persons %}
{% for person in members %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ person.last_name }}</td>
<td>{{ person.first_name }}</td>
<td>{{ person.get_sex_display }}</td>
<td>{{ person.date_of_birth }}</td>
<td>{{ person.absences_count }}</td>
<td>{{ person.excused }}</td>
<td>{{ person.excused_without_excuse_type }}</td>
{% for excuse_type in excuse_types %}
<td>{{ person|get_dict:excuse_type.count_label }}</td>
<td>{{ person.absence_count }}</td>
{% for absence_reason in absence_reasons %}
<td>{{ person|get_dict:absence_reason.count_label }}</td>
{% endfor %}
<td>{{ person.unexcused }}</td>
{% for excuse_type in excuse_types_not_absent %}
<td>{{ person|get_dict:excuse_type.count_label }}</td>
{% for absence_reason in absence_reasons_not_counted %}
<td>{{ person|get_dict:absence_reason.count_label }}</td>
{% endfor %}
<td>{{ person.tardiness }}'/{{ person.tardiness_count }}&times;</td>
<!-- TODO: First was person.tardiness; not shure sum is the right equivalent. -->
<td>{{ person.tardiness_sum }}'/{{ person.tardiness_count }}&times;</td>
{% for extra_mark in extra_marks %}
<td>{{ person|get_dict:extra_mark.count_label }}</td>
{% endfor %}
......
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