diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -37,7 +37,7 @@ def mention_list(request, year_slug): 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") + groups = Group.objects.filter(timetable=timetable.source, hidden=False).order_by("name") start, _ = get_week(*get_current_week()) end = start + datetime.timedelta(weeks=4) @@ -61,7 +61,7 @@ def group_list(request, year_slug, timetable_slug): return render(request, "group_list.html", {"timetable": timetable, "groups": groups}) -def timetable_common(request, obj, year=None, week=None): +def timetable_common(request, obj, year=None, week=None, timetable=None): current_year, current_week = get_current_or_next_week() is_old_timetable, provided_week = False, True @@ -84,27 +84,24 @@ def timetable_common(request, obj, year=None, week=None): "last_update": last_update, "year": year, "week": int(week), "is_old_timetable": is_old_timetable, - "group_mode": isinstance(obj, Group)}) + "group_mode": isinstance(obj, Group), + "timetable": timetable}) def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None): timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug) - group = get_object_or_404(Group, slug=group_slug, timetable=timetable) + group = get_object_or_404(Group, slug=group_slug, timetable=timetable.source) - if Group.objects.filter(timetable=timetable, mention=group.mention, - subgroup__startswith=group.subgroup).count() > 1: - subgroups = Group.objects.get_relevant_groups(timetable, mention=group.mention, - subgroup__startswith=group.subgroup) - return group_list_common(request, timetable, subgroups) - - return timetable_common(request, group, year, week) + return timetable_common(request, group, year, week, timetable) def calendars(request, year_slug, timetable_slug, group_slug): - group = get_object_or_404(Group, timetable__year__slug=year_slug, - timetable__slug=timetable_slug, slug=group_slug) + timetable = get_object_or_404(Timetable, year__slug=year_slug, + slug=timetable_slug) + group = get_object_or_404(Group, timetable=timetable.source, slug=group_slug) groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \ .order_by("length") - return render(request, "calendars.html", {"group": group, "groups": groups}) + return render(request, "calendars.html", {"timetable": timetable, + "group": group, "groups": groups}) def rooms(request): # On récupère les dates allant de cette semaine à dans un mois |