From d7dfa0c001a9b84541e1545e45d0536a87d6880e Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 19 Jan 2018 19:20:21 +0100 Subject: Liens permettant de naviguer sur les pages des semaines suivantes et précédentes --- templates/timetable.html | 7 ++++++- views.py | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/templates/timetable.html b/templates/timetable.html index 8fafeed..cc90ed5 100644 --- a/templates/timetable.html +++ b/templates/timetable.html @@ -1,4 +1,5 @@ {% extends "index.html" %} +{% load dt_week %} {% block head %}{% if group_mode %} @@ -18,4 +19,8 @@ {% if last_update %}Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}{% endif %}

{% include "timetable_common.html" %} - {% if group_mode %}

ICSRSSAtom

{% endif %}{% endblock %} +

+ {% if last_week is not None %}Semaine {{ last_week|dt_week }}{% if next_week is not None %} – {% endif %}{% endif %}{% if next_week is not None %}Semaine {{ next_week|dt_week }}{% endif %} + {% if group_mode %}{% if last_week is not None or next_week is not None %}
{% endif %} + ICSRSSAtom{% endif %} +

{% endblock %} diff --git a/views.py b/views.py index 0231c9e..10dcfa2 100644 --- a/views.py +++ b/views.py @@ -79,12 +79,19 @@ def timetable_common(request, obj, year=None, week=None, timetable=None): if not courses.exists() and provided_week: raise Http404 + # Récupération des semaines suivantes et précédentes pour les + # afficher proprement dans l’emploi du temps + last_week = getattr(Course.objects.get_courses(obj, begin__lt=start).last(), "begin", None) + next_week = getattr(Course.objects.get_courses(obj, begin__gte=end).first(), "begin", None) + last_update = courses.aggregate(Max("last_update"))["last_update__max"] grouped_courses = group_courses(courses) return render(request, "timetable.html", {"group": obj, "courses": grouped_courses, "last_update": last_update, "year": year, "week": int(week), + "last_week": last_week, + "next_week": next_week, "is_old_timetable": is_old_timetable, "group_mode": isinstance(obj, Group), "timetable": timetable}) -- cgit v1.2.1