aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-11-25 15:14:52 +0100
committerAlban Gruin2017-11-25 15:14:52 +0100
commitf333d363a78821ebab78fb9bb900d7aefbf6079c (patch)
tree4f0964afa138271429ad3f9dd8a2340c77236494
parentcbab00f4b745f4d80dd06a52699006d1d081be20 (diff)
Dans get_weeks(), l’annotation Count() ne sert à rien.
-rw-r--r--models.py7
-rw-r--r--views.py4
2 files changed, 5 insertions, 6 deletions
diff --git a/models.py b/models.py
index 59301e0..cd19259 100644
--- a/models.py
+++ b/models.py
@@ -158,9 +158,10 @@ class CourseManager(Manager):
return self.get_queryset() \
.filter(**criteria) \
.order_by("groups__name", "year", "week") \
- .annotate(_=Count(("groups", "year", "week", "begin")),
- year=ExtractYear("begin"),
- week=ExtractWeek("begin"))
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("groups__mention",
+ "groups__subgroup", "year", "week")
class Course(models.Model):
diff --git a/views.py b/views.py
index d4df8db..f1ec8d5 100644
--- a/views.py
+++ b/views.py
@@ -42,9 +42,7 @@ def group_list(request, year_slug, timetable_slug):
start, _ = get_week(*get_current_week())
end = start + datetime.timedelta(weeks=4)
- groups_weeks = Course.objects.get_weeks(begin__gte=start, begin__lt=end, groups__in=groups) \
- .values("groups__mention", "groups__subgroup",
- "year", "week")
+ 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: