From 641ec9956385177a0a2721a887f5288f26773006 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Sat, 7 Dec 2024 13:52:28 +0100
Subject: [PATCH] Fix templates for coursebook export

---
 .../alsijil/partials/person_overview.html     | 16 ++++-----
 .../alsijil/partials/register_coursebook.html | 34 +++++++++----------
 .../alsijil/print/register_for_group.html     | 12 +++----
 3 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/person_overview.html b/aleksis/apps/alsijil/templates/alsijil/partials/person_overview.html
index fa2fb386..6c91c347 100644
--- a/aleksis/apps/alsijil/templates/alsijil/partials/person_overview.html
+++ b/aleksis/apps/alsijil/templates/alsijil/partials/person_overview.html
@@ -1,6 +1,6 @@
 {% load static i18n data_helpers %}
 
-<h4>{% blocktrans with full_name=person.full_name %}Personal Overview: {{ person.full_name }}{% endblocktrans %}</h4>
+<h4>{% blocktrans with full_name=person.full_name %}Personal Overview: {{ full_name }}{% endblocktrans %}</h4>
 
 <h5>{% blocktrans %}Contact Details{% endblocktrans %}</h5>
 <table class="person-info">
@@ -86,17 +86,17 @@
   <thead>
   <tr>
     <th>{% trans 'Date' %}</th>
-    <th>{% trans 'Subj.' %}</th>
-    <th>{% trans 'Te.' %}</th>
+    <th>{% trans 'Subject' %}</th>
+    <th>{% trans 'Teachers' %}</th>
     <th>{% trans 'Absent' %}</th>
-    <th>{% trans 'Tard.' %}</th>
+    <th>{% trans 'Tardiness' %}</th>
   </tr>
   </thead>
 
   <tbody>
   {% for participation in person.notable_participations %}
     <tr>
-      <td>{{ participation.related_documentation.datetime_start.date }}</td>
+      <td>{{ participation.related_documentation.datetime_start }}</td>
       <td>
         {{ participation.related_documentation.subject.short_name }}
       </td>
@@ -115,8 +115,8 @@
   <thead>
   <tr>
     <th>{% trans 'Date' %}</th>
-    <th>{% trans 'Subj.' %}</th>
-    <th>{% trans 'Te.' %}</th>
+    <th>{% trans 'Subject' %}</th>
+    <th>{% trans 'Teacher' %}</th>
     <th colspan="2">{% trans 'Remarks' %}</th>
   </tr>
   </thead>
@@ -124,7 +124,7 @@
   <tbody>
   {% for note in person.new_personal_notes.all %}
     <tr>
-      <td>{{ note.documentation.datetime_start.date }}</td>
+      <td>{{ note.documentation.datetime_start }}</td>
       <td>
         {{ note.documentation.subject.short_name }}
       </td>
diff --git a/aleksis/apps/alsijil/templates/alsijil/partials/register_coursebook.html b/aleksis/apps/alsijil/templates/alsijil/partials/register_coursebook.html
index 01e05170..4149ee1c 100644
--- a/aleksis/apps/alsijil/templates/alsijil/partials/register_coursebook.html
+++ b/aleksis/apps/alsijil/templates/alsijil/partials/register_coursebook.html
@@ -5,7 +5,6 @@
 <table class="small-print">
   <thead>
   <tr>
-    <th></th>
     <th>{% trans 'Time' %}</th>
     <th>{% trans 'Subj.' %}</th>
     <th>{% trans 'Topic' %}</th>
@@ -15,9 +14,9 @@
   </tr>
   </thead>
   <tbody>
-    {% for documentation in group.documentations_by_day %}
-      {% ifchanged documentation.datetime_start.date %}
-        <tr><th colspan="6">{{ documentation.datetime_start.date|date:"D" }}</th></tr>
+    {% for doc in group.documentations_by_day %}
+      {% ifchanged doc.datetime_start.date %}
+        <tr><th colspan="6">{{ doc.datetime_start.date|date }}</th></tr>
       {% endifchanged %}
       <tr class="
               {% if doc.amends %}
@@ -27,6 +26,7 @@
                 {% if forloop.first %}
                   lessons-day-first
                 {% endif %}
+            {% endif %}
               ">
           <td class="lesson-pe">
             {% if doc.amends %}
@@ -40,7 +40,9 @@
             {% endif %}
           </td>
           <td class="lesson-subj">
-            {% include "chronos/partials/subject.html" with subject=doc.subject %}
+            {% if doc.subject %}
+                {{ doc.subject.short_name|default:doc.subject.name }}
+            {% endif %}
           </td>
           <td class="lesson-topic">
             {{ doc.topic }}
@@ -51,7 +53,7 @@
             {% for participation in doc.notable_participations %}
               {% if participation.absence_reason %}
                 <span class="lesson-note-absent">
-                  {{ participation.person.short_name }}
+                  {{ participation.person.full_name }}
                   <span style="color: {{ participation.absence_reason.colour }};">
                     ({{ participation.absence_reason.short_name }})
                   </span>
@@ -59,34 +61,32 @@
               {% endif %}
               {% if participation.tardiness %}
                 <span class="lesson-note-late">
-                  {{ participation.person.short_name }}
+                  {{ participation.person.full_name }}
                   ({{ participation.tardiness }}′)
                 </span>
               {% endif %}
-              {% for personal_note in doc.personal_notes.all %}
+            {% endfor %}
+            {% for personal_note in doc.personal_notes.all %}
                 {% if personal_note.extra_mark %}
-                  <span>
-                    {{ personal_note.person.short_name }}
+                    <span>
+                    {{ personal_note.person .full_name }}
                     ({{ personal_note.extra_mark.short_name }})
-                  </span>
+                    </span>
                 {% endif %}
                 {% if personal_note.note %}
-                  <span>
-                    {{ personal_note.person.short_name }}
+                    <span>
+                    {{ personal_note.person.full_name }}
                     ({{ personal_note.note }})
-                  </span>
+                    </span>
                 {% endif %}
-              {% endfor %}
             {% endfor %}
           </td>
           <td class="lesson-te">
-            <!-- TODO: Why only with topic? Was already like this. But does it have to be with the new data-model?  -->
             {% if doc.topic %}
               {{ doc.get_teachers_short_names|join:', ' }}
             {% endif %}
           </td>
         </tr>
-      {% endfor %}
     {% endfor %}
   </tbody>
 </table>
diff --git a/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html b/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html
index f056e411..22576332 100644
--- a/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html
+++ b/aleksis/apps/alsijil/templates/alsijil/print/register_for_group.html
@@ -3,7 +3,7 @@
 {% load static i18n %}
 
 {% block page_title %}
-  {% trans "Class Register:" %} {{ group.name }}
+  {% trans "Class Register" %}
 {% endblock %}
 
 {% block extra_head %}
@@ -13,17 +13,17 @@
 {% block content %}
   {% for group in groups %}
     {% if include_cover %}
-      {% include "alsijil/partials/register_cover.html" %}
+      {% include "alsijil/partials/register_cover.html" with group=group %}
       <div class="page-break">&nbsp;</div>
     {% endif %}
 
     {% if include_abbreviations %}
-      {% include "alsijil/partials/register_abbreviations.html" %}
+      {% include "alsijil/partials/register_abbreviations.html" with group=group %}
       <div class="page-break">&nbsp;</div>
     {% endif %}
 
     {% if include_members_table %}
-      {% include "alsijil/partials/register_members_table.html" %}
+      {% include "alsijil/partials/register_members_table.html" with group=group %}
       <div class="page-break">&nbsp;</div>
     {% endif %}
 
@@ -42,13 +42,13 @@
 
     {% if include_person_overviews %}
       {% for person in group.members_with_stats %}
-        {% include "alsijil/partials/person_overview.html" with person=person %}
+        {% include "alsijil/partials/person_overview.html" with person=person group=group %}
         <div class="page-break">&nbsp;</div>
       {% endfor %}
     {% endif %}
 
     {% if include_coursebook %}
-      {% include "alsijil/partials/register_coursebook.html" %}
+      {% include "alsijil/partials/register_coursebook.html" with group=group %}
     {% endif %}
   {% endfor %}
 {% endblock %}
-- 
GitLab