From 1b4731f85718d77db343607e68570797b7e0aae7 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Mon, 23 Jan 2017 09:11:30 +0100 Subject: Les semaines passées ne sont plus affichées dans la liste des emplois du temps disponibles --- views.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/views.py b/views.py index 28c8746..92e6dc9 100644 --- a/views.py +++ b/views.py @@ -13,14 +13,19 @@ def index(request): timetables = Timetable.objects.all() groups = Group.objects.filter(tp__isnull=False).order_by("name") + current_year, current_week, _ = timezone.now().isocalendar() + for group in groups: courses = Course.objects.get_courses_for_group(group).values("begin").annotate(count=Count("begin")) weeks = [] for course in courses: year, week, _ = course["begin"].isocalendar() - date, _ = get_week(year, week) - if date not in weeks: - weeks.append(date) + + if year >= current_year and week >= current_week: + date, _ = get_week(year, week) + if date not in weeks: + weeks.append(date) + group.weeks = weeks return render(request, "index.html", {"timetables": timetables, "groups": groups}) -- cgit v1.2.1