diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -40,7 +40,19 @@ def timetable(request, timetable_slug, year, week, group_slug): else: grouped_courses[-1].append(course) - return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "last_update": last_update.date, "week": week}) + return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": week}) + +def subscribe(request, timetable_slug, year, week, group_slug): + group = get_object_or_404(Group, slug=group_slug) + + if request.method == "POST": + subscription = Subscription(email=request.POST["email"], group=group) + subscription.save() + + return redirect("timetable", timetable_slug=timetable_slug, year=year, week=week, group_slug=group_slug) + else: + timetable = get_object_or_404(Timetable, slug=timetable_slug) + return render(request, "subscribe.html", {"timetable": timetable, "year": year, "week": week, "group": group}) def confirm_subscription(request, token): subscription = get_object_or_404(Subscription, token=token) |