diff --git a/aleksis/apps/alsijil/templates/alsijil/class_register/person.html b/aleksis/apps/alsijil/templates/alsijil/class_register/person.html index 304aae60e48a0a4292848e3a10ca93f0fb42c370..60b7c275670a0ba4a48a07160f8471b7d36902a1 100644 --- a/aleksis/apps/alsijil/templates/alsijil/class_register/person.html +++ b/aleksis/apps/alsijil/templates/alsijil/class_register/person.html @@ -125,30 +125,44 @@ <div class="collapsible-body"> <table> <tr> - <th colspan="2">{% trans 'Absences' %}</th> + <th colspan="3">{% trans 'Absences' %}</th> <td>{{ stat.absences_count }}</td> </tr> <tr> - <td rowspan="{{ excuse_types.count|add:2 }}" class="hide-on-small-only">{% trans "thereof" %}</td> - <td rowspan="{{ excuse_types.count|add:2 }}" class="hide-on-med-and-up"></td> - <th class="truncate">{% trans 'Excused' %}</th> + <td rowspan="{{ excuse_types.count|add:3 }}" class="hide-on-small-only">{% trans "thereof" %}</td> + <td rowspan="{{ excuse_types.count|add:3 }}" class="hide-on-med-and-up"></td> + <th colspan="2">{% trans 'Excused' %}</th> <td>{{ stat.excused }}</td> </tr> + <tr> + <td rowspan="{{ excuse_types.count|add:1 }}" class="hide-on-small-only">{% trans "thereof" %}</td> + <td rowspan="{{ excuse_types.count|add:1 }}" class="hide-on-med-and-up"></td> + <th colspan="2" class="truncate">{% trans 'Without Excuse Type' %}</th> + <td>{{ stat.excused_no_excuse_type }}</td> + </tr> {% for excuse_type in excuse_types %} - <th>{{ excuse_type.name }}</th> - <td>{{ stat|get_dict:excuse_type.count_label }}</td> + <tr> + <th>{{ excuse_type.name }}</th> + <td>{{ stat|get_dict:excuse_type.count_label }}</td> + </tr> {% endfor %} <tr> - <th>{% trans 'Unexcused' %}</th> + <th colspan="2">{% trans 'Unexcused' %}</th> <td>{{ stat.unexcused }}</td> </tr> + {% for excuse_type in excuse_types_not_missed %} + <tr> + <th colspan="3">{{ excuse_type.name }}</th> + <td>{{ stat|get_dict:excuse_type.count_label }}</td> + </tr> + {% endfor %} <tr> - <th colspan="2">{% trans 'Tardiness' %}</th> + <th colspan="3">{% trans 'Tardiness' %}</th> <td>{{ stat.tardiness }}'/{{ stat.tardiness_count }} ×</td> </tr> {% for extra_mark in extra_marks %} <tr> - <th colspan="2">{{ extra_mark.name }}</th> + <th colspan="3">{{ extra_mark.name }}</th> <td>{{ stat|get_dict:extra_mark.count_label }}</td> </tr> {% endfor %} diff --git a/aleksis/apps/alsijil/views.py b/aleksis/apps/alsijil/views.py index 2d8968207f7f94ec8eac1717a68435fbe555d996..a7ef660986f4c3ad61d744fae38167858c6a6bf8 100644 --- a/aleksis/apps/alsijil/views.py +++ b/aleksis/apps/alsijil/views.py @@ -893,7 +893,8 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp note.set_object_permission_checker(checker) personal_notes_list.append(note) context["personal_notes"] = personal_notes_list - context["excuse_types"] = ExcuseType.objects.all() + context["excuse_types"] = ExcuseType.objects.filter(count_as_missed_lesson=True) + context["excuse_types_not_missed"] = ExcuseType.objects.filter(count_as_missed_lesson=False) form = PersonOverviewForm(request, request.POST or None, queryset=allowed_personal_notes) if request.method == "POST" and request.user.has_perm( @@ -927,13 +928,25 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp continue stat.update( - personal_notes.filter(absent=True).aggregate(absences_count=Count("absent")) + personal_notes + .filter(absent=True) + .exclude(excuse_type__count_as_missed_lesson=False) + .aggregate(absences_count=Count("absent")) ) stat.update( personal_notes.filter( - absent=True, excused=True, excuse_type__isnull=True + absent=True, excused=True + ).exclude( + excuse_type__count_as_missed_lesson=False ).aggregate(excused=Count("absent")) ) + stat.update( + personal_notes.filter( + absent=True, excused=True, excuse_type__isnull=True + ).exclude( + excuse_type__count_as_missed_lesson=False + ).aggregate(excused_no_excuse_type=Count("absent")) + ) stat.update( personal_notes.filter(absent=True, excused=False).aggregate( unexcused=Count("absent") @@ -959,7 +972,6 @@ def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResp stats.append((school_term, stat)) context["stats"] = stats - context["excuse_types"] = excuse_types context["extra_marks"] = extra_marks # Build filter with own form and logic as django-filter can't work with different models