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

Show excuse types in full register

parent 7da96b07
No related branches found
No related tags found
1 merge request!64Resolve "Add support for multiple excuse types"
Pipeline #3036 passed
table.small-print { table.small-print, td.small-print, th.small-print {
font-size: 10pt; font-size: 10pt;
} }
...@@ -25,7 +25,7 @@ tr.lessons-day-first { ...@@ -25,7 +25,7 @@ tr.lessons-day-first {
border-top: 3px solid rgba(0, 0, 0, 0.3); border-top: 3px solid rgba(0, 0, 0, 0.3);
} }
th.lessons-day-head { th.lessons-day-head, td.rotate, th.rotate {
text-align: center; text-align: center;
transform: rotate(-90deg); transform: rotate(-90deg);
} }
......
{% load i18n %} {% load i18n %}
{% for note in notes %} {% for note in notes %}
<span class="{% if note.excused %}green-text{% else %}red-text{% endif %}">{{ note.person }} <span class="{% if note.excused %}green-text{% else %}red-text{% endif %}">{{ note.person }}
{% if note.excused %}{% trans "(e)" %}{% else %}{% trans "(u)" %}{% endif %}{% if not forloop.last %},{% endif %} {% if note.excused %}{% if note.excuse_type %}({{ note.excuse_type.short_name }}){% else %}{% trans "(e)" %}{% endif %}{% else %}{% trans "(u)" %}{% endif %}{% if not forloop.last %},{% endif %}
</span> </span>
{% endfor %} {% endfor %}
...@@ -74,9 +74,13 @@ ...@@ -74,9 +74,13 @@
<th>{% trans 'First name' %}</th> <th>{% trans 'First name' %}</th>
<th>{% trans 'Sex' %}</th> <th>{% trans 'Sex' %}</th>
<th>{% trans 'Date of birth' %}</th> <th>{% trans 'Date of birth' %}</th>
<th>{% trans 'Absences' %}</th> <th>{% trans '(a)' %}</th>
<th>{% trans 'Unexcused' %}</th> <th>{% trans "(e)" %}</th>
<th>{% trans 'Tard.' %}</th> {% for excuse_type in excuse_types %}
<th>({{ excuse_type.short_name }})</th>
{% endfor %}
<th>{% trans '(u)' %}</th>
<th>{% trans '(b)' %}</th>
</tr> </tr>
</thead> </thead>
...@@ -89,6 +93,10 @@ ...@@ -89,6 +93,10 @@
<td>{{ person.get_sex_display }}</td> <td>{{ person.get_sex_display }}</td>
<td>{{ person.date_of_birth }}</td> <td>{{ person.date_of_birth }}</td>
<td>{{ person.absences_count }}</td> <td>{{ person.absences_count }}</td>
<td>{{ person.excused }}</td>
{% for excuse_type in excuse_types %}
<td>{{ person|get_dict:excuse_type.count_label }}</td>
{% endfor %}
<td>{{ person.unexcused }}</td> <td>{{ person.unexcused }}</td>
<td>{{ person.tardiness }}'</td> <td>{{ person.tardiness }}'</td>
</tr> </tr>
...@@ -226,11 +234,27 @@ ...@@ -226,11 +234,27 @@
<h5>{% trans 'Absences and tardiness' %}</h5> <h5>{% trans 'Absences and tardiness' %}</h5>
<table> <table>
<thead>
<tr> <tr>
<th>{% trans 'Absences' %}</th> <th colspan="2">{% trans 'Absences' %}</th>
<td>{{ person.absences_count }}</td>
</tr>
<tr>
<td rowspan="{{ excuse_types.count|add:2 }}" style="width: 16mm;"
class="rotate small-print">{% trans "thereof" %}</td>
<th>{% trans 'Excused' %}</th>
<td>{{ person.excused }}</td>
</tr>
{% for excuse_type in excuse_types %}
<th>{{ excuse_type.name }}</th>
<td>{{ person|get_dict:excuse_type.count_label }}</td>
{% endfor %}
<tr>
<th>{% trans 'Unexcused' %}</th> <th>{% trans 'Unexcused' %}</th>
<th>{% trans 'Tardiness' %}</th> <td>{{ person.unexcused }}</td>
</tr>
<tr>
<th colspan="2">{% trans 'Tardiness' %}</th>
<td>{{ person.tardiness }}'</td>
</tr> </tr>
</thead> </thead>
...@@ -269,8 +293,12 @@ ...@@ -269,8 +293,12 @@
<td> <td>
{% if note.absent %} {% if note.absent %}
{% trans 'Yes' %} {% trans 'Yes' %}
{% if note.escused %} {% if note.excused %}
({% trans 'e' %}) {% if note.excuse_type %}
({{ note.excuse_type.short_name }})
{% else %}
({% trans 'e' %})
{% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
</td> </td>
...@@ -347,8 +375,12 @@ ...@@ -347,8 +375,12 @@
{{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}. {{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}.
{% if note.excused %} {% if note.excused %}
<span class="lesson-note-excused"> <span class="lesson-note-excused">
({% trans 'e' %}) {% if note.excuse_type %}
</span> ({{ note.excuse_type.short_name }})
{% else %}
({% trans 'e' %})
{% endif %}
</span>
{% endif %} {% endif %}
</span> </span>
{% endif %} {% endif %}
...@@ -358,8 +390,12 @@ ...@@ -358,8 +390,12 @@
({{ note.late }}′) ({{ note.late }}′)
{% if note.excused %} {% if note.excused %}
<span class="lesson-note-excused"> <span class="lesson-note-excused">
({% trans 'e' %}) {% if note.excuse_type %}
</span> ({{ note.excuse_type.short_name }})
{% else %}
({% trans 'e' %})
{% endif %}
</span>
{% endif %} {% endif %}
</span> </span>
{% endif %} {% endif %}
......
...@@ -313,6 +313,14 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: ...@@ -313,6 +313,14 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
absences_count=Count( absences_count=Count(
"personal_notes__absent", filter=Q(personal_notes__absent=True) "personal_notes__absent", filter=Q(personal_notes__absent=True)
), ),
excused=Count(
"personal_notes__absent",
filter=Q(
personal_notes__absent=True,
personal_notes__excused=True,
personal_notes__excuse_type__isnull=True,
),
),
unexcused=Count( unexcused=Count(
"personal_notes__absent", "personal_notes__absent",
filter=Q(personal_notes__absent=True, personal_notes__excused=False), filter=Q(personal_notes__absent=True, personal_notes__excused=False),
...@@ -320,6 +328,19 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: ...@@ -320,6 +328,19 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
tardiness=Sum("personal_notes__late"), tardiness=Sum("personal_notes__late"),
) )
for excuse_type in ExcuseType.objects.all():
persons = persons.annotate(
**{
excuse_type.count_label: Count(
"personal_notes__absent",
filter=Q(
personal_notes__absent=True,
personal_notes__excuse_type=excuse_type,
),
)
}
)
# FIXME Move to manager # FIXME Move to manager
personal_note_filters = PersonalNoteFilter.objects.all() personal_note_filters = PersonalNoteFilter.objects.all()
for personal_note_filter in personal_note_filters: for personal_note_filter in personal_note_filters:
...@@ -337,6 +358,7 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: ...@@ -337,6 +358,7 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
context["persons"] = persons context["persons"] = persons
context["personal_note_filters"] = personal_note_filters context["personal_note_filters"] = personal_note_filters
context["excuse_types"] = ExcuseType.objects.all()
context["group"] = group context["group"] = group
context["weeks"] = weeks context["weeks"] = weeks
context["periods_by_day"] = periods_by_day context["periods_by_day"] = periods_by_day
......
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