aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-10-10 21:16:27 +0200
committerAlban Gruin2017-10-10 21:16:27 +0200
commitd4dd17cc3ef13f2322ccab292fb6bc544c753f49 (patch)
treef77617887abe53bcba9a702d66647628a47073d2 /views.py
parent604fab9f88b510599d175bf6545ee49f5f82addd (diff)
parent5939a5dc3747e8b872dd4cb0c622621c25b72c5d (diff)
Merge branch 'stable/0.10.z' into prod/pa1ch/0.10.zv0.10.5-pa1ch
Diffstat (limited to 'views.py')
-rw-r--r--views.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/views.py b/views.py
index bd93712..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
@@ -80,15 +81,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"))
- if courses.count() == 0:
+ courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
+ if courses.count() == 0 and provided_week:
raise Http404
+ 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": courses.first().last_update__max,
+ "last_update": last_update,
"year": year, "week": int(week),
"is_old_timetable": is_old_timetable})