aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-09-07 22:22:46 +0200
committerAlban Gruin2017-09-07 22:22:46 +0200
commitf18b2cc4f4aa7b2ed2d7801c19ddf75acbb6abc2 (patch)
treebcff554a2e98460075780e339141f7adf289704c /views.py
parenta79e87a3ecfd505846c04f7949b1036a102430ed (diff)
Remplacement de la page d’acceuil par la liste des années, menant sur
une liste de mentions, puis une liste de groupes, etc etc.
Diffstat (limited to 'views.py')
-rw-r--r--views.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/views.py b/views.py
index 176f174..363fddb 100644
--- a/views.py
+++ b/views.py
@@ -18,12 +18,21 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.core.mail import send_mail
from django.conf import settings
from django.template import Context, loader
+from django.db.models import Count
from .forms import SubscribeForm
from .models import Timetable, LastUpdate, Group, Subscription, Course
from .utils import get_current_week, get_week, group_courses
def index(request):
+ years = Timetable.objects.order_by("year").values("year").annotate(count=Count("year"))
+ return render(request, "index.html", {"years": years})
+
+def mention_list(request, year):
+ timetables = Timetable.objects.order_by("name").filter(year=year)
+ return render(request, "mention_list.html", {"year": year, "timetables": timetables})
+
+def timetables_list(request):
timetables = Timetable.objects.order_by("name")
groups = Group.objects.get_relevant_groups().order_by("name")
@@ -44,7 +53,7 @@ def index(request):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "index.html", {"timetables": timetables, "groups": groups})
+ return render(request, "timetables_list.html", {"timetables": timetables, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None: