diff options
author | Alban Gruin | 2017-01-24 17:36:50 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-24 17:36:50 +0100 |
commit | afc9f62cc44c6f6a05e46b46ce53a3c49e7ead6e (patch) | |
tree | 89936b40c7966d7bf7888f2537173df701714926 /views.py | |
parent | 69fde609d36c63891cdbaad8428884aa1873cde3 (diff) |
Le tri des semaines affichées est effectué directement dans la base de données
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -14,17 +14,17 @@ def index(request): groups = Group.objects.filter(tp__isnull=False).order_by("name") current_year, current_week, _ = timezone.now().isocalendar() + start, _ = get_week(current_year, current_week) for group in groups: - courses = Course.objects.get_courses_for_group(group).values("begin").annotate(count=Count("begin")) + courses = Course.objects.get_courses_for_group(group, begin__gte=start).values("begin").annotate(count=Count("begin")) weeks = [] for course in courses: year, week, _ = course["begin"].isocalendar() + date, _ = get_week(year, week) - if year >= current_year and week >= current_week: - date, _ = get_week(year, week) - if date not in weeks: - weeks.append(date) + if date not in weeks: + weeks.append(date) group.weeks = weeks |