diff options
author | Alban Gruin | 2017-09-08 11:53:49 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-08 11:53:49 +0200 |
commit | 57ffdbf0658042069abcf0b1f9184ff69a3139e2 (patch) | |
tree | 85ab2f0cf55fc85dec62b065b7eb246b7de46e4c /views.py | |
parent | 0a287c2013bcfd1cb71926fbd0835170369521f7 (diff) |
Ajout de l’année dans les urls
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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() |