aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'views.py')
-rw-r--r--views.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/views.py b/views.py
index 31a89f5..f48509d 100644
--- a/views.py
+++ b/views.py
@@ -34,8 +34,8 @@ def mention_list(request, year_slug):
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
def group_list(request, year_slug, timetable_slug):
- get_object_or_404(Year, slug=year_slug)
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ year_obj = get_object_or_404(Year, slug=year_slug)
+ timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
@@ -57,12 +57,13 @@ def group_list(request, year_slug, timetable_slug):
return render(request, "group_list.html", {"timetable": timetable, "groups": groups})
-def timetable(request, timetable_slug, group_slug, year=None, week=None):
+def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
year, week = get_current_week()
start, end = get_week(int(year), int(week))
+ get_object_or_404(Year, slug=year_slug)
timetable = get_object_or_404(Timetable, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
last_update = get_object_or_404(LastUpdate, timetable=timetable, week=week, year=year)
@@ -72,8 +73,9 @@ def timetable(request, timetable_slug, group_slug, year=None, week=None):
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
-def subscribe(request, timetable_slug, group_slug, year, week):
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
+def subscribe(request, year_slug, timetable_slug, group_slug, year, week):
+ year_obj = get_object_or_404(Year, slug=year_slug)
+ timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
if request.method == "POST":
@@ -87,7 +89,7 @@ def subscribe(request, timetable_slug, group_slug, year, week):
context = Context({"group": group, "admins": settings.ADMINS, "token": subscription.token, "domain": settings.DEFAULT_DOMAIN})
send_mail("Confirmation de l’abonnemenent", template.render(context), settings.DEFAULT_FROM_EMAIL, [request.POST["email"]])
- return redirect("timetable", timetable_slug=timetable_slug, group_slug=group_slug, year=year, week=int(week))
+ return redirect("timetable", year_slug=year_slug, timetable_slug=timetable_slug, group_slug=group_slug, year=year, week=int(week))
else:
form = SubscribeForm()