From e6ccfea46083c4cd228be57565be006e8c3c59f8 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 10 Oct 2017 18:07:54 +0200 Subject: Correction de l’affichage de la dernière mise à jour --- views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'views.py') diff --git a/views.py b/views.py index bd93712..5988536 100644 --- a/views.py +++ b/views.py @@ -80,15 +80,15 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No if group.children.count(): return group_list_common(request, timetable, Group.objects.get_relevant_children(group)) - courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) \ - .annotate(Max("last_update")) + courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) if courses.count() == 0: raise Http404 + last_update = courses.aggregate(Max("last_update")) grouped_courses = group_courses(courses) return render(request, "timetable.html", {"group": group, "courses": grouped_courses, - "last_update": courses.first().last_update__max, + "last_update": last_update["last_update__max"], "year": year, "week": int(week), "is_old_timetable": is_old_timetable}) -- cgit v1.2.1 From 5939a5dc3747e8b872dd4cb0c622621c25b72c5d Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 10 Oct 2017 18:26:37 +0200 Subject: Si la semaine courante n’a pas de cours existant, la page générale existe quand même --- views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'views.py') diff --git a/views.py b/views.py index 5988536..2100972 100644 --- a/views.py +++ b/views.py @@ -65,10 +65,11 @@ def group_list(request, year_slug, timetable_slug): def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): current_year, current_week = get_current_or_next_week() - is_old_timetable = False + is_old_timetable, provided_week = False, True if year is None or week is None: year, week = current_year, current_week + provided_week = False elif (int(year), int(week)) < (current_year, current_week): is_old_timetable = True @@ -81,14 +82,14 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No return group_list_common(request, timetable, Group.objects.get_relevant_children(group)) courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) - if courses.count() == 0: + if courses.count() == 0 and provided_week: raise Http404 - last_update = courses.aggregate(Max("last_update")) + last_update = courses.aggregate(Max("last_update"))["last_update__max"] grouped_courses = group_courses(courses) return render(request, "timetable.html", {"group": group, "courses": grouped_courses, - "last_update": last_update["last_update__max"], + "last_update": last_update, "year": year, "week": int(week), "is_old_timetable": is_old_timetable}) -- cgit v1.2.1