From 898a7b84a193d60a6cc9496aeb3ded4c9c16acbc Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Sat, 15 Apr 2023 00:05:54 +0200
Subject: [PATCH] Correct the column order in the person statistics table

---
 CHANGELOG.rst                                 |  1 +
 .../alsijil/partials/persons_with_stats.html  | 20 ++++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 540930966..0cc0df6a5 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -14,6 +14,7 @@ Fixed
 * In some cases, pages showing the count of extra marks and lessons with custom excuse types of
   persons threw an error.
 * The redirection to generated class register PDF printouts did not work.
+* Some columns in the table showing statistics for the members of a group were labled wrongly.
 
 `3.0b0`_ - 2022-02-28
 ---------------------
diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/persons_with_stats.html b/aleksis/apps/alsijil/templates/alsijil/partials/persons_with_stats.html
index bb60dbbd0..69ce9c6c9 100644
--- a/aleksis/apps/alsijil/templates/alsijil/partials/persons_with_stats.html
+++ b/aleksis/apps/alsijil/templates/alsijil/partials/persons_with_stats.html
@@ -12,11 +12,13 @@
     <th rowspan="2">{% trans "Name" %}</th>
     <th rowspan="2">{% trans "Primary group" %}</th>
     <th colspan="{{ excuse_types.count|add:4 }}">{% trans "Absences" %}</th>
-    <th colspan="{{ excuse_types_not_absent.count }}">{% trans "Uncounted Absences" %}</th>
-    <th rowspan="2">{% trans "Tardiness" %}</th>
+    {% if excuse_types_not_absent %}
+      <th colspan="{{ excuse_types_not_absent.count }}">{% trans "Uncounted Absences" %}</th>
+    {% endif %}
     {% if extra_marks %}
       <th colspan="{{ extra_marks.count }}">{% trans "Extra marks" %}</th>
     {% endif %}
+    <th rowspan="2">{% trans "Tardiness" %}</th>
     <th rowspan="2"></th>
   </tr>
   <tr class="hide-on-large-only">
@@ -36,12 +38,12 @@
         ({{ excuse_type.short_name }})
       </th>
     {% endfor %}
-    <th class="truncate chip-height">{% trans "Tardiness" %}</th>
     {% for extra_mark in extra_marks %}
       <th class="chip-height">
         {{ extra_mark.short_name }}
       </th>
     {% endfor %}
+    <th class="truncate chip-height">{% trans "Tardiness" %}</th>
     <th rowspan="2"></th>
   </tr>
   <tr class="hide-on-med-and-down">
@@ -110,12 +112,6 @@
           </span>
         </td>
       {% endfor %}
-      <td>
-        <span class="chip orange white-text" title="{% trans "Tardiness" %}">
-          {% firstof person.tardiness|to_time|time:"H\h i\m"  "–" %}
-        </span>
-        <span class="chip orange white-text" title="{% trans "Count of tardiness" %}">{{ person.tardiness_count }} &times;</span>
-      </td>
       {% for extra_mark in extra_marks %}
         <td>
           <span class="chip grey white-text" title="{{ extra_mark.name }}">
@@ -123,6 +119,12 @@
           </span>
         </td>
       {% endfor %}
+      <td>
+        <span class="chip orange white-text" title="{% trans "Tardiness" %}">
+          {% firstof person.tardiness|to_time|time:"H\h i\m"  "–" %}
+        </span>
+        <span class="chip orange white-text" title="{% trans "Count of tardiness" %}">{{ person.tardiness_count }} &times;</span>
+      </td>
 
       <td>
         <a class="btn primary waves-effect waves-light" href="{% url "overview_person" person.pk %}">
-- 
GitLab