diff --git a/aleksis/apps/chronos/templates/chronos/timetable.html b/aleksis/apps/chronos/templates/chronos/timetable.html index 4605d70b690b1168903910b21fd6bda4e6b4bd79..397eca05446fb5d609144a460a0c6270fe660f40 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, weekday, date in weekdays_short %} <div class="col s2 hide-on-large-only"> <div class="card timetable-title-card"> <div class="card-content"> <span class="card-title"> - {{ day.1 }} + {{ weekday }} </span> + {{ date }} {# {% 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, weekday, date in weekdays %} <div class="col s2 hide-on-med-only"> <div class="card timetable-title-card"> <div class="card-content"> <span class="card-title"> - {{ day.1 }} + {{ weekday }} </span> + {{ date }} {# {% 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, weekday, date in weekdays %} <div class="card timetable-mobile-title-card"> <div class="card-content"> <span class="card-title"> - {{ day.1 }} + {{ weekday }} </span> + {{ date }} {# {% 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 f1c06bb4a533ef95e75112c98f3e514cfac2a7b3..e94b3feab5dcd4532bddc7fd4fcfe4248ebf8477 100644 --- a/aleksis/apps/chronos/views.py +++ b/aleksis/apps/chronos/views.py @@ -151,12 +151,21 @@ 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] - ) - context["weekdays_short"] = dict( - TimePeriod.WEEKDAY_CHOICES_SHORT[TimePeriod.weekday_min : TimePeriod.weekday_max + 1] - ) + + # Build lists with weekdays and corresponding dates (long and short variant) + context["weekdays"] = [ + (key, weekday, wanted_week[key]) + for key, weekday in TimePeriod.WEEKDAY_CHOICES[ + TimePeriod.weekday_min : TimePeriod.weekday_max + 1 + ] + ] + context["weekdays_short"] = [ + (key, weekday, wanted_week[key]) + for key, weekday 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 context["type"] = type_