aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2018-01-19 19:20:21 +0100
committerAlban Gruin2018-01-19 19:54:09 +0100
commitd7dfa0c001a9b84541e1545e45d0536a87d6880e (patch)
treedd563d246239934ff4d83ceeab892dbdafb31d8b /views.py
parent7a4bdfda6df3ca46f4805c145a42793cacc0809f (diff)
Liens permettant de naviguer sur les pages des semaines suivantes et précédentes
Diffstat (limited to 'views.py')
-rw-r--r--views.py7
1 files changed, 7 insertions, 0 deletions
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})