diff options
author | Alban Gruin | 2017-01-22 19:10:26 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-22 19:10:26 +0100 |
commit | e0d2b72c30ec26ca953c52d6bec33dc030d18947 (patch) | |
tree | 1861a7392ddcc062cae796bf0e43170036c75c80 /views.py | |
parent | c0f72b8c7062eceda834beae57efbe95d94eb4f9 (diff) |
Ajout d'un formulaire pour s'abonner à un emploi du temps
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) |