From 0b3fabb03d98cf2455818aa2650df1ab86846431 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 28 Sep 2017 21:35:35 +0200 Subject: Si un utilisateur consulte un groupe qui a des enfants, on lui propose une liste de groupes enfants --- views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/views.py b/views.py index 404b7cb..82ef639 100644 --- a/views.py +++ b/views.py @@ -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: -- cgit v1.2.1