aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'views.py')
-rw-r--r--views.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/views.py b/views.py
index b4518f3..dbcf937 100644
--- a/views.py
+++ b/views.py
@@ -33,20 +33,18 @@ def index(request):
return render(request, "index.html", {"timetables": timetables, "groups": groups})
-def timetable(request, timetable_slug, year, week, group_slug):
+def timetable(request, group_slug, year, week):
start, end = get_week(int(year), int(week))
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
- group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
-
+ 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=timetable, week=week, year=year)
+ last_update = LastUpdate.objects.get(timetable=group.timetable, week=week, year=year)
grouped_courses = group_courses(courses)
- return render(request, "timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
+ 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, year, week, group_slug):
+def subscribe(request, group_slug, year, week):
group = get_object_or_404(Group, slug=group_slug)
if request.method == "POST":
@@ -59,12 +57,11 @@ def subscribe(request, timetable_slug, year, week, group_slug):
context = Context({"group": group, "admins": settings.ADMINS, "token": subscription.token})
send_mail("Confirmation de l'abonnemenent", template.render(context), settings.DEFAULT_FROM_EMAIL, [request.POST["email"]])
- return redirect("timetable", timetable_slug=timetable_slug, year=year, week=int(week), group_slug=group_slug)
+ return redirect("timetable", group_slug=group_slug, year=year, week=int(week))
else:
form = SubscribeForm()
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
- return render(request, "subscribe.html", {"timetable": timetable, "year": year, "week": week, "group": group, "form": form})
+ return render(request, "subscribe.html", {"year": year, "week": week, "group": group, "form": form})
def confirm_subscription(request, token):
subscription = get_object_or_404(Subscription, token=token)
@@ -78,7 +75,7 @@ def confirm_subscription(request, token):
if day >= 6:
year, week, _ = (timezone.now() + datetime.timedelta(weeks=1)).isocalendar()
- return redirect("timetable", timetable_slug=subscription.group.timetable.slug, year=year, week=week, group_slug=subscription.group.slug)
+ return redirect("timetable", group_slug=subscription.group.slug, year=year, week=week)
def cancel_subscription(request, token):
subscription = get_object_or_404(Subscription, token=token)