From 2dbfdc7604a1beb394d412ee8f1b202475aa574e Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Wed, 18 Mar 2020 15:51:14 +0100
Subject: [PATCH] Show dates in column headings in weekly timetable view

Close #68
---
 .../chronos/templates/chronos/timetable.html    | 17 ++++++++++-------
 aleksis/apps/chronos/views.py                   | 14 ++++++++++++--
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/aleksis/apps/chronos/templates/chronos/timetable.html b/aleksis/apps/chronos/templates/chronos/timetable.html
index 4fa91ac6..b017b2dc 100644
--- a/aleksis/apps/chronos/templates/chronos/timetable.html
+++ b/aleksis/apps/chronos/templates/chronos/timetable.html
@@ -124,13 +124,14 @@
 
       </div>
       {# Show short weekdays on tablets #}
-      {% for day in weekdays_short.items %}
+      {% for i, day in weekdays_short.items %}
         <div class="col s2 hide-on-large-only">
           <div class="card timetable-title-card">
             <div class="card-content">
                             <span class="card-title">
-                                {{ day.1 }}
+                                {{ day.0 }}
                             </span>
+              {{ day.1 }}
               {#              {% if day.1 %}#}
               {#                <span class="badge new blue center-align holiday-badge">{{ day.1.0 }}</span>#}
               {#              {% endif %}#}
@@ -140,13 +141,14 @@
       {% endfor %}
 
       {# Show long weekdays elsewere #}
-      {% for day in weekdays.items %}
+      {% for i, day in weekdays.items %}
         <div class="col s2 hide-on-med-only">
           <div class="card timetable-title-card">
             <div class="card-content">
                             <span class="card-title">
-                                {{ day.1 }}
+                                {{ day.0 }}
                             </span>
+              {{ day.1 }}
               {#              {% if day.1 %}#}
               {#                <span class="badge new blue center-align holiday-badge">{{ day.1.0 }}</span>#}
               {#              {% endif %}#}
@@ -176,12 +178,13 @@
 
   {# show 5 seperate ones on mobiles #}
   <div class="timetable-plan hide-on-med-and-up">
-    {% for day in weekdays.items %}
+    {% for i, day in weekdays.items %}
       <div class="card timetable-mobile-title-card">
         <div class="card-content">
                     <span class="card-title">
-                        {{ day.1 }}
+                        {{ day.0 }}
                     </span>
+          {{ day.1 }}
           {#          {% if day.1 %}#}
           {#            <span class="badge new blue center-align holiday-badge">{{ day.1.0 }}</span>#}
           {#          {% endif %}#}
@@ -195,7 +198,7 @@
           </div>
 
           {% for weekday, lessons in lesson_periods_period.items %}
-            {% if forloop.counter0|add:"1" == day.0 %}
+            {% if forloop.counter0 == i %}
               <div class="col s8">
                 {# A lesson #}
                 {% include "chronos/partials/lesson.html" with lessons=lessons %}
diff --git a/aleksis/apps/chronos/views.py b/aleksis/apps/chronos/views.py
index daad66d7..21de994e 100644
--- a/aleksis/apps/chronos/views.py
+++ b/aleksis/apps/chronos/views.py
@@ -151,10 +151,20 @@ def timetable(
     context["lesson_periods"] = OrderedDict(sorted(per_period.items()))
     context["periods"] = TimePeriod.get_times_dict()
     context["weekdays"] = dict(
-        TimePeriod.WEEKDAY_CHOICES[TimePeriod.weekday_min : TimePeriod.weekday_max + 1]
+        [
+            (key, (item, wanted_week[key]))
+            for key, item in TimePeriod.WEEKDAY_CHOICES[
+                TimePeriod.weekday_min : TimePeriod.weekday_max + 1
+            ]
+        ]
     )
     context["weekdays_short"] = dict(
-        TimePeriod.WEEKDAY_CHOICES_SHORT[TimePeriod.weekday_min : TimePeriod.weekday_max + 1]
+        [
+            (key, (item, wanted_week[key]))
+            for key, item in TimePeriod.WEEKDAY_CHOICES_SHORT[
+                TimePeriod.weekday_min : TimePeriod.weekday_max + 1
+            ]
+        ]
     )
     context["weeks"] = get_weeks_for_year(year=wanted_week.year)
     context["week"] = wanted_week
-- 
GitLab