diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -5,7 +5,7 @@ from django.utils import timezone from edt.forms import SubscribeForm from edt.models import Timetable, LastUpdate, Group, Subscription, Course -from edt.utils import get_week +from edt.utils import get_week, group_courses import datetime @@ -34,12 +34,7 @@ def timetable(request, timetable_slug, year, week, 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) - grouped_courses = [] - for i, course in enumerate(courses): - if i == 0 or courses[i - 1].begin.day != course.begin.day: - grouped_courses.append([course]) - else: - grouped_courses[-1].append(course) + 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": week}) |