aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-10-27 21:51:12 +0200
committerAlban Gruin2017-10-27 21:51:12 +0200
commit7ef57a0226fa25b8ea5e9a6ff5526889dc300649 (patch)
treeddcac97876e52c0e64cb8d1a4431cb9d087f5ef2 /views.py
parentdf3cb623a79d925e6af048bc88e607094c6b692e (diff)
Ajout d’une page pour lister les calendriers disponibles
Diffstat (limited to 'views.py')
-rw-r--r--views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/views.py b/views.py
index 9c38524..76b7127 100644
--- a/views.py
+++ b/views.py
@@ -17,6 +17,7 @@ import datetime
from django.conf import settings
from django.db.models import Max
+from django.db.models.functions import Length
from django.http import Http404
from django.shortcuts import get_object_or_404, render
@@ -95,5 +96,19 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
"year": year, "week": int(week),
"is_old_timetable": is_old_timetable})
+def calendar_list(request, year_slug, timetable_slug, group_slug):
+ """Affiche une liste des ICS disponibles pour un groupe."""
+ # On commence par récupérer l’emploi du temps associé, puis le groupe
+ # Si la récupération de l’un d’entre eux échoue, on affiche une erreur 404.
+ timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug)
+ group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
+
+ # On récupère les groupes « parents » au groupe spécifié.
+ groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \
+ .order_by("length")
+
+ # On réutilise encore la template principale
+ return render(request, "index.html", {"group": group, "elements": groups})
+
def contact(request):
return render(request, "contact.html", {"email": settings.ADMINS[0][1]})