diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -31,10 +31,7 @@ def mention_list(request, year_slug): return render(request, "mention_list.html", {"year": year, "timetables": timetables}) -def group_list(request, year_slug, timetable_slug): - timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) - groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name") - +def group_list_common(request, timetable, groups): year, week = get_current_week() start, _ = get_week(year, week) groups_weeks = Course.objects.get_weeks(begin__gte=start, timetable=timetable) \ @@ -58,6 +55,11 @@ def group_list(request, year_slug, timetable_slug): return render(request, "group_list.html", {"timetable": timetable, "groups": groups}) +def group_list(request, year_slug, timetable_slug): + timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) + groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name") + return group_list_common(request, timetable, groups) + def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): current_year, current_week = get_current_week() is_old_timetable = False @@ -72,6 +74,9 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) group = get_object_or_404(Group, slug=group_slug, timetable=timetable) + if group.children.count(): + return group_list_common(request, timetable, group.children.order_by("name")) + courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) \ .annotate(Max("last_update")) if courses.count() == 0: |