diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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) |