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

Adapt the person_overview to the new datamodel

parent b1e27b20
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
Pipeline #193386 failed
......@@ -17,7 +17,7 @@ from aleksis.core.util.pdf import generate_pdf_from_template
from aleksis.apps.cursus.models import Course
from aleksis.apps.kolego.models.absence import AbsenceReason
from .models import ExtraMark
from .models import ExtraMark, NewPersonalNote, Documentation, ParticipationStatus
from .model_extensions import annotate_person_statistics_for_school_term
......@@ -170,9 +170,39 @@ def generate_full_register_printout(
context["absence_reasons_not_counted"] = AbsenceReason.objects.filter(count_as_absent=False)
context["extra_marks"] = ExtraMark.objects.all()
if include_members_table:
if include_members_table or include_person_overviews:
group = group.prefetch_related("members")
if include_person_overviews:
group = group.prefetch_related(
Prefetch(
"members__participations",
queryset=ParticipationStatus.objects
.filter(
# TODO: Not shure this filter works here as intended = test
Q(absence_reason__isnull=False)
| Q(tardiness__isnull=False)
)
.select_related("absence_reason")
.prefetch_related(
Prefetch(
"related_documentation",
queryset=Documentation.objects.select_related("subject").prefetch_related("teachers"),
),
)
),
Prefetch(
"members__new_personal_notes",
queryset=NewPersonalNote.objects.prefetch_related(
Prefetch(
"documentation",
queryset=Documentation.objects.select_related("subject").prefetch_related("teachers"),
),
"extra_mark",
)
),
)
if include_teachers_and_subjects_table:
group = group.prefetch_related(
Prefetch("courses", queryset=Course.objects.select_related("subject")),
......@@ -185,7 +215,7 @@ def generate_full_register_printout(
group = group[0]
context["group"] = group
if include_members_table:
if include_members_table or include_person_overviews:
context["members"] = annotate_person_statistics_for_school_term(group.members.all(), group.school_term, group)
# OLD
......
......@@ -43,39 +43,23 @@
<table>
<tr>
<th colspan="3">{% trans 'Absences' %}</th>
<td>{{ person.absences_count }}</td>
<td>{{ person.absence_count }}</td>
</tr>
<tr>
<td rowspan="{{ excuse_types.count|add:3 }}" style="width: 16mm;"
class="rotate small-print">{% trans "thereof" %}</td>
<th colspan="2">{% trans 'Excused' %}</th>
<td>{{ person.excused }}</td>
</tr>
<tr>
<td rowspan="{{ excuse_types.count|add:1 }}" style="width: 16mm;"
class="rotate small-print">{% trans "thereof" %}</td>
<th>{% trans "Without excuse type" %}</th>
<td>{{ person.excused_without_excuse_type }}</td>
</tr>
{% for excuse_type in excuse_types %}
{% for for absence_reason in absence_reasons %}
<tr>
<th>{{ excuse_type.name }}</th>
<td>{{ person|get_dict:excuse_type.count_label }}</td>
<th>{{ absence_reason.name }}</th>
<td>{{ person|get_dict:absence_reason.count_label }}</td>
</tr>
{% endfor %}
<tr>
<th colspan="2">{% trans 'Unexcused' %}</th>
<td>{{ person.unexcused }}</td>
</tr>
{% for excuse_type in excuse_types_not_absent %}
{% for for absence_reason in absence_reasons_not_counted %}
<tr>
<th colspan="3">{{ excuse_type.name }}</th>
<td>{{ person|get_dict:excuse_type.count_label }}</td>
<th colspan="3">{{ absence_reason.name }}</th>
<td>{{ person|get_dict:absence_reason.count_label }}</td>
</tr>
{% endfor %}
<tr>
<th colspan="3">{% trans 'Tardiness' %}</th>
<td>{{ person.tardiness }}'/{{ person.tardiness_count }}&times;</td>
<td>{{ person.tardiness_sum }}'/{{ person.tardiness_count }}&times;</td>
</tr>
</table>
</div>
......@@ -95,64 +79,57 @@
</div>
</div>
<h5>{% trans 'Relevant personal notes' %}</h5>
<h5>{% trans 'Relevant participation statuses' %}</h5>
<table class="small-print">
<thead>
<tr>
<th>{% trans 'Date' %}</th>
<th>{% trans 'Pe.' %}</th>
<th>{% trans 'Subj.' %}</th>
<th>{% trans 'Te.' %}</th>
<th>{% trans 'Absent' %}</th>
<th>{% trans 'Tard.' %}</th>
</tr>
</thead>
<tbody>
{% for participation in person.participations %}
<tr>
<td>{{ participation.documentation.datetime_start.date }}</td>
<td>
{{ participation.documentation.subject.short_name }}
</td>
<!-- TODO: Should probably use short_names -->
<td>{{ participation.note.documentation.teachers.all|join:', ' }}</td>
<td>{{ participation.absence_reason.short_name }}</td>
<td>{{ participation.tardiness }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h5>{% trans 'Relevant personal notes' %}</h5>
<table class="small-print">
<thead>
<tr>
<th>{% trans 'Date' %}</th>
<th>{% trans 'Subj.' %}</th>
<th>{% trans 'Te.' %}</th>
<th colspan="2">{% trans 'Remarks' %}</th>
</tr>
</thead>
<tbody>
{% for note in person.filtered_notes %}
{% if note.absent or note.tardiness or note.remarks or note.extra_marks.all %}
{% for note in person.new_personal_notes %}
{% if note.note or note.extra_marks.all %}
<tr>
{% if note.date %}
<td>{{ note.date }}</td>
<td>{{ note.register_object.period.period }}</td>
{% else %}
<td colspan="2">
{{ note.register_object.date_start }} {{ note.register_object.period_from.period }}.–{{ note.register_object.date_end }}
{{ note.register_object.period_to.period }}.
</td>
{% endif %}
<td>
{% if note.register_object.label_ != "event" %}
{{ note.register_object.get_subject.short_name }}
{% else %}
{% trans "Event" %}
{% endif %}
</td>
<td>{{ note.register_object.teacher_short_names }}</td>
<td>
{% if note.absent %}
{% trans 'Yes' %}
{% if note.excused %}
{% if note.excuse_type %}
({{ note.excuse_type.short_name }})
{% else %}
({% trans 'e' %})
{% endif %}
{% endif %}
{% endif %}
</td>
<td>
{% if note.tardiness %}
{{ note.tardiness }}'
{% endif %}
</td>
<td>{{ note.documentation.datetime_start.date }}</td>
<td>
{% for extra_mark in note.extra_marks.all %}
{{ extra_mark.short_name }}{% if not forloop.last %},{% endif %}
{% endfor %}
{{ note.documentation.subject.short_name }}
</td>
<td>{{ note.remarks }}</td>
<!-- TODO: Should probably use short_names -->
<td>{{ note.documentation.teachers.all|join:', ' }}</td>
<td>{{ note.extra_mark.short_name }}</td>
<td>{{ note.note }}</td>
</tr>
{% endif %}
{% endfor %}
......
......@@ -43,7 +43,7 @@
{% endif %}
{% if include_person_overviews %}
{% for person in persons %}
{% for person in members %}
{% include "alsijil/partials/person_overview.html with person=person only %}
<div class="page-break">&nbsp;</div>
{% 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