aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-27 22:00:41 +0100
committerAlban Gruin2017-01-27 22:00:41 +0100
commitfa450f840641969cd3fea769300536ce603229cd (patch)
tree291bf584f7f1fb5bd3c9a15d2f705823c14a75e6 /views.py
parent0f2525a12ea0ed03d3d33a48b112d3d80a622b75 (diff)
parentcfd2969cd9fa18e6148e97c1066341b1c1add6cf (diff)
Merge branch 'dev/db' into dev/db-groupby
Diffstat (limited to 'views.py')
-rw-r--r--views.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/views.py b/views.py
index 24473d1..c549cfb 100644
--- a/views.py
+++ b/views.py
@@ -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})