diff options
author | Alban Gruin | 2017-09-28 21:35:35 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-28 21:35:35 +0200 |
commit | 0b3fabb03d98cf2455818aa2650df1ab86846431 (patch) | |
tree | 104df0a289b52419ff022755caf75e887510c4dc | |
parent | cd2c473be7ebc33d7992441ae3ff1bf52785488c (diff) |
Si un utilisateur consulte un groupe qui a des enfants, on lui propose
une liste de groupes enfants
-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: |