diff options
-rw-r--r-- | views.py | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -35,11 +35,14 @@ def mention_list(request, year_slug): return render(request, "index.html", {"year": year, "elements": timetables}) -def group_list_common(request, timetable, 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.filter(timetable=timetable, hidden=False).order_by("name") + start, _ = get_week(*get_current_week()) end = start + datetime.timedelta(weeks=4) - groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end, timetable=timetable) \ + groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end, groups__in=groups) \ .values("groups__mention", "groups__subgroup", "year", "week") @@ -57,12 +60,8 @@ def group_list_common(request, timetable, groups): if hasattr(group, "weeks"): group.weeks.sort() - 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.filter(timetable=timetable).order_by("name") - return group_list_common(request, timetable, groups) + return render(request, "group_list.html", {"timetable": timetable, "groups": groups}) def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): current_year, current_week = get_current_or_next_week() |