aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-02-05 13:40:25 +0100
committerAlban Gruin2017-02-05 13:40:25 +0100
commit5363b70a7840f937f710e0a85fa83e48a35e083a (patch)
tree35371c3fc4b76a533293e97715faba87e4160fe5 /views.py
parent49eca350c06d9c3e2c45a1215e2d98acee0535c1 (diff)
RĂ©-introduction du slug de l'emploi du temps dans les urls
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 6204d9f..9f38032 100644
--- a/views.py
+++ b/views.py
@@ -34,7 +34,7 @@ def index(request):
return render(request, "index.html", {"timetables": timetables, "groups": groups})
-def timetable(request, group_slug, year=None, week=None):
+def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
year, week, day = timezone.now().isocalendar()
if day >= 6:
@@ -42,16 +42,18 @@ def timetable(request, group_slug, year=None, week=None):
start, end = get_week(int(year), int(week))
- group = get_object_or_404(Group, slug=group_slug)
- courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
- last_update = LastUpdate.objects.get(timetable=group.timetable, week=week, year=year)
+ timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
+ courses = Course.objects.get_courses_for_group(group, timetable=timetable, begin__gte=start, begin__lt=end)
+ last_update = LastUpdate.objects.get(timetable=timetable, week=week, year=year)
grouped_courses = group_courses(courses)
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
-def subscribe(request, group_slug, year, week):
- group = get_object_or_404(Group, slug=group_slug)
+def subscribe(request, timetable_slug, group_slug, year, week):
+ timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
if request.method == "POST":
form = SubscribeForm(request.POST)