aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--views.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/views.py b/views.py
index ebcf4ff..1fc74b5 100644
--- a/views.py
+++ b/views.py
@@ -49,13 +49,16 @@ def mention_list(request, year_slug):
def group_list(request, year_slug, timetable_slug):
- timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug)
+ timetable = get_object_or_404(Timetable, year__slug=year_slug,
+ slug=timetable_slug)
start, _ = get_week(*get_current_week())
end = start + datetime.timedelta(weeks=4)
- groups = Group.objects.get_relevant_groups(start, source=timetable.source, hidden=False)
- groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end, groups__in=groups)
+ groups = Group.objects.get_relevant_groups(start, source=timetable.source,
+ hidden=False)
+ groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end,
+ groups__in=groups)
for group in groups:
for group_week in groups_weeks:
@@ -97,20 +100,25 @@ def timetable_common(request, obj, year=None, week=None, timetable=None):
# Récupération des semaines suivantes et précédentes pour les
# afficher proprement dans l’emploi du temps
- last_week = getattr(Course.objects.get_courses(obj, begin__lt=start).last(), "begin", None)
- next_week = getattr(Course.objects.get_courses(obj, begin__gte=end).first(), "begin", None)
+ last_course = Course.objects.get_courses(obj, begin__lt=start).last()
+ last_week = getattr(last_course, "begin", None)
+
+ next_course = Course.objects.get_courses(obj, begin__gte=end).first()
+ next_week = getattr(next_course, "begin", None)
last_update = courses.aggregate(Max("last_update"))["last_update__max"]
grouped_courses = group_courses(courses)
- return render(request, "timetable.html", {"group": obj, "courses": grouped_courses,
- "last_update": last_update,
- "year": year, "week": int(week),
- "last_week": last_week,
- "next_week": next_week,
- "is_old_timetable": is_old_timetable,
- "group_mode": isinstance(obj, Group),
- "timetable": timetable})
+ return render(request, "timetable.html",
+ {"group": obj, "courses": grouped_courses,
+ "last_update": last_update,
+ "year": year, "week": int(week),
+ "last_week": last_week,
+ "next_week": next_week,
+ "is_old_timetable": is_old_timetable,
+ "group_mode": isinstance(obj, Group),
+ "timetable": timetable})
+
def timetable(request, year_slug, timetable_slug, group_slug,
year=None, week=None):