diff options
author | Alban Gruin | 2017-01-27 21:55:33 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-27 21:55:33 +0100 |
commit | cfd2969cd9fa18e6148e97c1066341b1c1add6cf (patch) | |
tree | 0d5691aeb40ce0859874735c9814233df0c88d93 /views.py | |
parent | 64145d7d43d8e6fbda5630e6e643ef259b6fa881 (diff) |
Nouveau traitement des semaines, qui double apparement la vitesse de traitement
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -18,18 +18,17 @@ def index(request): current_year, current_week, _ = timezone.now().isocalendar() start, _ = get_week(current_year, current_week) + groups_weeks = Course.objects.get_weeks(start) for group in groups: - 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 date not in weeks: - weeks.append(date) - - group.weeks = weeks + for group_week in groups_weeks: + if group.corresponds_to(group_week.timetable_id, group_week.mention, group_week.subgroup, group_week.td, group_week.tp): + if not hasattr(group, "weeks"): + group.weeks = [] + + date, _ = get_week(group_week.year, group_week.week) + if date not in group.weeks: + group.weeks.append(date) return render(request, "index.html", {"timetables": timetables, "groups": groups}) |