aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--templates/timetable.html7
-rw-r--r--views.py7
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 }} &ndash; 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> &ndash; <a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> &ndash; <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 %} &ndash; {% 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> &ndash; <a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> &ndash; <a href="{% url "atom" timetable.year.slug timetable.slug group.slug %}">Atom</a>{% endif %}
+ </p>{% 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})