From f9e06f5a9421a955852ff87e011a1d315a512855 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Sun, 11 Aug 2024 16:33:39 +0200
Subject: [PATCH] Update substitutions print templates for calendar

---
 .../templates/chronos/partials/group.html     |  4 +---
 .../templates/chronos/partials/groups.html    |  2 +-
 .../chronos/partials/groups_part.html         | 10 +++------
 .../templates/chronos/partials/headerbox.html | 22 +++++++++----------
 .../templates/chronos/partials/rooms.html     |  7 +-----
 .../templates/chronos/partials/subject.html   |  2 +-
 .../chronos/partials/subs/badge.html          |  2 +-
 .../chronos/partials/subs/colour.html         |  2 +-
 .../chronos/partials/subs/period.html         | 15 +++++++++----
 .../chronos/partials/subs/subject.html        | 14 +++---------
 .../templates/chronos/partials/teachers.html  |  7 +-----
 .../chronos/substitutions_print.html          | 20 ++++++++---------
 12 files changed, 45 insertions(+), 62 deletions(-)

diff --git a/aleksis/apps/chronos/templates/chronos/partials/group.html b/aleksis/apps/chronos/templates/chronos/partials/group.html
index d2e345d5..3105150c 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/group.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/group.html
@@ -1,3 +1 @@
-<a href="{% url "timetable" "group" item.pk %}">
-  {{ item.short_name }}{% if not forloop.last %},{% endif %}
-</a>
+{{ item.short_name }}{% if not forloop.last %},{% endif %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/groups.html b/aleksis/apps/chronos/templates/chronos/partials/groups.html
index fb85c6d4..61bf6927 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/groups.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/groups.html
@@ -1,5 +1,5 @@
 {% if groups.count == 1 and groups.0.parent_groups.all and request.site.preferences.chronos__use_parent_groups %}
-  {% include "chronos/partials/groups_part.html" with groups=groups.0.parent_groups.all no_collapsible=no_collapsible %}
+  {% include "chronos/partials/groups_part.html" with groups=groups.0.parent_groups.all %}
 {% else %}
   {% include "chronos/partials/groups_part.html" with groups=groups no_collapsible=no_collapsible %}
 {% endif %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/groups_part.html b/aleksis/apps/chronos/templates/chronos/partials/groups_part.html
index edafcb19..d4c8f9f2 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/groups_part.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/groups_part.html
@@ -1,7 +1,3 @@
-{% if groups.count > request.site.preferences.chronos__shorten_groups_limit and request.user.person.preferences.chronos__shorten_groups and not no_collapsible %}
-  {% include "components/text_collapsible.html" with template="chronos/partials/group.html" qs=groups %}
-{% else %}
-  {% for group in groups %}
-    {% include "chronos/partials/group.html" with item=group %}
-  {% endfor %}
-{% endif %}
+{% for group in groups %}
+  {% include "chronos/partials/group.html" with item=group %}
+{% endfor %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/headerbox.html b/aleksis/apps/chronos/templates/chronos/partials/headerbox.html
index 1ed1e7de..c3862168 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/headerbox.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/headerbox.html
@@ -1,53 +1,53 @@
 {% load i18n %}
 
 {% if affected_teachers or affected_groups or absent_teachers or absent_groups %}
-  <div class="{% if not print %}card{% endif %}">
-    <div class="{% if not print %}card-content{% endif %}">
+  <div>
+    <div>
       {% if absent_teachers %}
         <div class="row no-margin">
-          <div class="col {% if not print %}s12 m3{% else %}s3{% endif %}">
+          <div class="col">
             <strong class="truncate">
               {% trans "Absent teachers" %}
             </strong>
           </div>
-          <div class="col {% if not print %}s12 m9{% else %}s9{% endif %} black-text-a">
+          <div class="col">
             {% include "chronos/partials/teachers.html" with teachers=absent_teachers %}
           </div>
         </div>
       {% endif %}
       {% if absent_groups %}
         <div class="row no-margin">
-          <div class="col {% if not print %}s12 m3{% else %}s3{% endif %}">
+          <div class="col">
             <strong class="truncate">
               {% trans "Absent groups" %}
             </strong>
           </div>
-          <div class="col {% if not print %}s12 m9{% else %}s9{% endif %} black-text-a">
+          <div class="col">
             {% include "chronos/partials/groups.html" with groups=absent_groups no_collapsible=True %}
           </div>
         </div>
       {% endif %}
       {% if affected_teachers %}
         <div class="row no-margin">
-          <div class="col {% if not print %}s12 m3{% else %}s3{% endif %}">
+          <div class="col">
             <strong class="truncate">
               {% trans "Affected teachers" %}
             </strong>
           </div>
-          <div class="col {% if not print %}s12 m9{% else %}s9{% endif %} black-text-a">
+          <div class="col">
             {% include "chronos/partials/teachers.html" with teachers=affected_teachers %}
           </div>
         </div>
       {% endif %}
       {% if affected_groups %}
         <div class="row no-margin">
-          <div class="col {% if not print %}s12 m3{% else %}s3{% endif %}">
+          <div class="col">
             <strong class="truncate">
               {% trans "Affected groups" %}
             </strong>
           </div>
-          <div class="col {% if not print %}s12 m9{% else %}s9{% endif %} black-text-a">
-            {% include "chronos/partials/groups.html" with groups=affected_groups no_collapsible=True %}
+          <div class="col">
+            {% include "chronos/partials/groups.html" with groups=affected_groups %}
           </div>
         </div>
       {% endif %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/rooms.html b/aleksis/apps/chronos/templates/chronos/partials/rooms.html
index 1e429881..e1f895c7 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/rooms.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/rooms.html
@@ -1,8 +1,3 @@
 {% for room in rooms %}
-  <span data-position="bottom" class="tooltipped"
-        data-tooltip="{{ room }}">
-      <a href="{% url "timetable" "room" room.pk %}">
-          {{ room.short_name }}{% if not forloop.last %},{% endif %}
-      </a>
-  </span>
+  {{ room.short_name|default:room.name }}{% if not forloop.last %},{% endif %}
 {% endfor %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/subject.html b/aleksis/apps/chronos/templates/chronos/partials/subject.html
index e326c75a..c6f305ab 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/subject.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/subject.html
@@ -1,3 +1,3 @@
 <strong>
-  <span data-position="bottom" class="tooltipped" data-tooltip="{{ subject.name }}">{{ subject.short_name }}</span>
+  {{ subject.short_name|default:subject.name }}
 </strong>
diff --git a/aleksis/apps/chronos/templates/chronos/partials/subs/badge.html b/aleksis/apps/chronos/templates/chronos/partials/subs/badge.html
index c8072442..f0210546 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/subs/badge.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/subs/badge.html
@@ -1,5 +1,5 @@
 {% load i18n %}
 
-{% if sub.cancelled %}
+{% if el.cancelled %}
   <span class="badge new green">{% trans "Cancelled" %}</span>
 {% endif %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/subs/colour.html b/aleksis/apps/chronos/templates/chronos/partials/subs/colour.html
index e59b37fe..06ccab26 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/subs/colour.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/subs/colour.html
@@ -1,4 +1,4 @@
-{% if item.el.cancelled %}
+{% if el.cancelled %}
   green-text
 {% else %}
   black-text
diff --git a/aleksis/apps/chronos/templates/chronos/partials/subs/period.html b/aleksis/apps/chronos/templates/chronos/partials/subs/period.html
index 4ba77063..874631a7 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/subs/period.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/subs/period.html
@@ -1,7 +1,14 @@
+{% load i18n %}
 <strong>
-  {% if el.datetime_start %}
-    {{ el.datetime_start.time }} - {{ el.datetime_end.time }}
-  {% elif el.date_start %}
-    {{ el.date_start }} - {{ el.date_end }}
+  {% if el.REFERENCE_OBJECT.slot_number_start and el.REFERENCE_OBJECT.slot_number_end %}
+    {% if el.REFERENCE_OBJECT.slot_number_start == el.REFERENCE_OBJECT.slot_number_end %}
+      {{ el.REFERENCE_OBJECT.slot_number_start }}.
+    {% else %}
+      {{ el.REFERENCE_OBJECT.slot_number_start }}.–{{ el.REFERENCE_OBJECT.slot_number_end }}.
+    {% endif %}
+  {% elif el.DTSTART.dt.time %}
+    {{ el.DTSTART.dt.time }} - {{ el.DTSTART.dt.time }}
+  {% else %}
+    {% trans "all day" %}
   {% endif %}
 </strong>
diff --git a/aleksis/apps/chronos/templates/chronos/partials/subs/subject.html b/aleksis/apps/chronos/templates/chronos/partials/subs/subject.html
index dcbfa4be..3e907e1f 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/subs/subject.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/subs/subject.html
@@ -2,25 +2,17 @@
 
 {% if not el.amends.subject and not el.subject %}
   {% if el.amends.title %}
-    <span data-position="bottom" class="tooltipped" data-tooltip="{{ el.amends.title }}">
     <s>{{ el.amends.title }}</s>
   {% endif %}
   {% if el.title %}
-    <span data-position="bottom" class="tooltipped" data-tooltip="{{ el.title }}">
     <s>{{ el.title }}</s>
   {% endif %}
 {% elif el.cancelled %}
-  <span data-position="bottom" class="tooltipped" data-tooltip="{{ el.subject.short_name }}">
-  <s>{{ el.subject.short_name }}</s>
-</span>
+  <s>{% include "chronos/partials/subject.html" with subject=el.amends.subject %}</s>
 {% elif el.subject and el.amends.subject %}
-  <span data-position="bottom" class="tooltipped" data-tooltip="{{ el.amends.subject.name }}">
-  <s>{{ el.amends.subject.short_name }}</s>
-</span>
+  <s>{% include "chronos/partials/subject.html" with subject=el.amends.subject %}</s>
   →
-  <span data-position="bottom" class="tooltipped" data-tooltip="{{ el.subject.name }}">
-  <strong>{{ el.subject.short_name }}</strong>
-</span>
+  <strong>{% include "chronos/partials/subject.html" with subject=el.subject %}</strong>
 {% elif el.subject and not el.amends.subject %}
   {% include "chronos/partials/subject.html" with subject=el.subject %}
 {% else %}
diff --git a/aleksis/apps/chronos/templates/chronos/partials/teachers.html b/aleksis/apps/chronos/templates/chronos/partials/teachers.html
index d7ec9719..f506b4b1 100644
--- a/aleksis/apps/chronos/templates/chronos/partials/teachers.html
+++ b/aleksis/apps/chronos/templates/chronos/partials/teachers.html
@@ -1,8 +1,3 @@
 {% for teacher in teachers %}
-  <span data-position="bottom" class="tooltipped"
-        data-tooltip="{{ teacher }}">
-      <a href="{% url "timetable" "teacher" teacher.pk %}">
-          {{ teacher.short_name }}{% if not forloop.last %},{% endif %}
-      </a>
-  </span>
+  {{ teacher.short_name|default:teacher.full_name }}{% if not forloop.last %},{% endif %}
 {% endfor %}
diff --git a/aleksis/apps/chronos/templates/chronos/substitutions_print.html b/aleksis/apps/chronos/templates/chronos/substitutions_print.html
index 10243a1a..04dc4cf2 100644
--- a/aleksis/apps/chronos/templates/chronos/substitutions_print.html
+++ b/aleksis/apps/chronos/templates/chronos/substitutions_print.html
@@ -18,7 +18,7 @@
 
     {% include "core/partials/announcements.html" with announcements=c.announcements show_recipients=1 %}
 
-    {% include "chronos/partials/headerbox.html" with absent_teachers=c.absent_teachers absent_groups=c.absent_groups print=1 %}
+    {% include "chronos/partials/headerbox.html" with absent_teachers=c.absent_teachers absent_groups=c.absent_groups affected_teachers=c.affected_teachers affected_groups=c.affected_groups %}
 
     <table class="substitutions">
       <thead>
@@ -47,30 +47,30 @@
 
       <tbody>
       {% for item in c.substitutions %}
-        {% ifchanged item.el.group_names %}
+        {% ifchanged item.el.REFERENCE_OBJECT.group_names %}
           </tbody>
           <tbody class="{% cycle "striped" "not-striped" %}">
         {% endifchanged %}
 
-        <tr class="{% include "chronos/partials/subs/colour.html" with item=item %}">
+        <tr class="{% include "chronos/partials/subs/colour.html" with el=item.el.REFERENCE_OBJECT %}">
           <td>
-            {% include "chronos/partials/subs/groups.html" with type=item.type el=item.el %}
+            {% include "chronos/partials/subs/groups.html" with el=item.el.REFERENCE_OBJECT %}
           </td>
           <td>
-            {% include "chronos/partials/subs/period.html" with type=item.type el=item.el item=item %}
+            {% include "chronos/partials/subs/period.html" with el=item.el %}
           </td>
           <td>
-            {% include "chronos/partials/subs/teachers.html" with type=item.type el=item.el %}
+            {% include "chronos/partials/subs/teachers.html" with el=item.el.REFERENCE_OBJECT %}
           </td>
           <td>
-            {% include "chronos/partials/subs/subject.html" with type=item.type el=item.el %}
+            {% include "chronos/partials/subs/subject.html" with  el=item.el.REFERENCE_OBJECT %}
           </td>
           <td>
-            {% include "chronos/partials/subs/rooms.html" with type=item.type el=item.el %}
+            {% include "chronos/partials/subs/rooms.html" with  el=item.el.REFERENCE_OBJECT %}
           </td>
           <td>
-            {% include "chronos/partials/subs/badge.html" with sub=item.el %}
-            {% include "chronos/partials/subs/comment.html" with el=item.el %}
+            {% include "chronos/partials/subs/badge.html" with el=item.el.REFERENCE_OBJECT %}
+            {% include "chronos/partials/subs/comment.html" with el=item.el.REFERENCE_OBJECT %}
           </td>
         </tr>
       {% endfor %}
-- 
GitLab