diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py index 3b27ed81a79dafb02241f1588901eb3836eb7296..b11824974a37a6fdac121cd946acbfd9d65391ae 100644 --- a/biscuit/apps/chronos/models.py +++ b/biscuit/apps/chronos/models.py @@ -24,6 +24,14 @@ class TimePeriod(models.Model): def __str__(self): return '%s, %d. period (%s - %s)' % (self.weekday, self.period, self.time_start, self.time_end) + @classmethod + def get_times_dict(cls): + periods = {} + for period in cls.objects.all(): + periods[period.period] = (period.time_start, period.time_end) + + return periods + class Subject(models.Model): abbrev = models.CharField(verbose_name=_( diff --git a/biscuit/apps/chronos/templates/chronos/tt_week.html b/biscuit/apps/chronos/templates/chronos/tt_week.html index 6bc250004c573ec620367e64fb2e4a39e57d2382..c07d17de16fd064b4560f0341eb1e09ca58c0a5d 100644 --- a/biscuit/apps/chronos/templates/chronos/tt_week.html +++ b/biscuit/apps/chronos/templates/chronos/tt_week.html @@ -1,6 +1,6 @@ {# -*- engine:django -*- #} {% extends "core/base.html" %} -{% load bootstrap4 %} +{% load bootstrap4 i18n %} {% block page_title %}Timetable{% endblock %} @@ -9,6 +9,42 @@ {{ filter_descs }} </p> + <div class="float-left"> + <ul class="list-group"> + <li class="list-group-item active"> + {% blocktrans %}Times{% endblocktrans %} + </li> + </ul> + <div class="container"> + {% for num, times in periods.items %} + <div class="row"> + <div class="col-sm"> + <div class="card" style="width: 18rem; {% if lesson.colour_fg %} color: {{ lesson.colour_fg }}; {% endif %} {% if lesson.colour_bg %} background-color: {{ lesson.colour_bg }}; {% endif %}"> + <div class="card-body"> + <div class="row"> + <div class="col-sm"> + <span class="card-title">{{ num }}.</span> + </div> + </div> + <div class="row"> + <div class="col-sm"> + <span class="card-text">{{ times.0}}</span> + </div> + <div class="col-sm"> + <span class="card-text">-</span> + </div> + <div class="col-sm"> + <span class="card-text">{{ times.1 }}</span> + </div> + </div> + </div> + </div> + </div> + </div> + {% endfor %} + </div> + </div> + {% for weekday, lesson_periods_day in lesson_periods.items %} {% include "chronos/tt_day.html" with lesson_periods=lesson_periods_day %} {% endfor %} diff --git a/biscuit/apps/chronos/views.py b/biscuit/apps/chronos/views.py index e52840d80b8bfb902c9d584c1dc5737f32d0fc43..776f7e923da39883ccb496588cd5e8d99626a8f0 100644 --- a/biscuit/apps/chronos/views.py +++ b/biscuit/apps/chronos/views.py @@ -8,7 +8,7 @@ from biscuit.apps.cambro.models import Room from biscuit.core.decorators import admin_required from biscuit.core.models import Group, Person -from .models import LessonPeriod +from .models import LessonPeriod, TimePeriod @login_required @@ -42,5 +42,6 @@ def timetable(request): context['lesson_periods'] = OrderedDict(sorted(per_day.items())) context['filter_descs'] = ', '.join(filter_descs) + context['periods'] = TimePeriod.get_times_dict() return render(request, 'chronos/tt_week.html', context)