diff options
author | Alban Gruin | 2018-01-19 19:20:21 +0100 |
---|---|---|
committer | Alban Gruin | 2018-01-19 19:54:09 +0100 |
commit | d7dfa0c001a9b84541e1545e45d0536a87d6880e (patch) | |
tree | dd563d246239934ff4d83ceeab892dbdafb31d8b | |
parent | 7a4bdfda6df3ca46f4805c145a42793cacc0809f (diff) |
Liens permettant de naviguer sur les pages des semaines suivantes et précédentes
-rw-r--r-- | templates/timetable.html | 7 | ||||
-rw-r--r-- | views.py | 7 |
2 files changed, 13 insertions, 1 deletions
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 %} <meta name="description" content="Emploi du temps du groupe {{ group }} – Semaine {{ week }}" /> @@ -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 %} </p> {% include "timetable_common.html" %} - {% if group_mode %}<p class="subscribe"><a href="{% url "calendars" timetable.year.slug timetable.slug group.slug %}">ICS</a> – <a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> – <a href="{% url "atom" timetable.year.slug timetable.slug group.slug %}">Atom</a></p>{% endif %}{% endblock %} + <p class="subscribe"> + {% if last_week is not None %}<a href="{% url "timetable" timetable.year.slug timetable.slug group.slug last_week.year last_week|dt_week %}">Semaine {{ last_week|dt_week }}</a>{% if next_week is not None %} – {% endif %}{% endif %}{% if next_week is not None %}<a href="{% url "timetable" timetable.year.slug timetable.slug group.slug next_week.year next_week|dt_week %}"">Semaine {{ next_week|dt_week }}</a>{% endif %} + {% if group_mode %}{% if last_week is not None or next_week is not None %}<br />{% endif %} + <a href="{% url "calendars" timetable.year.slug timetable.slug group.slug %}">ICS</a> – <a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> – <a href="{% url "atom" timetable.year.slug timetable.slug group.slug %}">Atom</a>{% endif %} + </p>{% endblock %} @@ -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}) |