From 10bca4899aeb607b86480f35fc8c9db6bb7c6714 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 5 Feb 2017 13:59:51 +0100 Subject: Filtrage par emploi du temps global lors de la récupération des cours pour un groupe --- models.py | 2 +- views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index 2f130a3..af136af 100644 --- a/models.py +++ b/models.py @@ -130,7 +130,7 @@ class CourseManager(GroupedManager): return qs.annotate(week=RawSQL("""cast(strftime("%%W", "begin") as integer)""", []), year=extractYear) def get_courses_for_group(self, group, **filters): - return self.get_queryset().filter(Q(groups__td__isnull=True) | Q(groups__td=group.td), Q(groups__tp__isnull=True) | Q(groups__tp=group.tp), groups__mention=group.mention, groups__subgroup=group.subgroup, **filters).order_by("begin") + return self.get_queryset().filter(Q(groups__td__isnull=True) | Q(groups__td=group.td), Q(groups__tp__isnull=True) | Q(groups__tp=group.tp), groups__mention=group.mention, groups__subgroup=group.subgroup, timetable=group.timetable, **filters).order_by("begin") def get_weeks(self, **criteria): qs = self.get_queryset().filter(**criteria) diff --git a/views.py b/views.py index 9f38032..d777594 100644 --- a/views.py +++ b/views.py @@ -44,7 +44,7 @@ def timetable(request, timetable_slug, group_slug, year=None, week=None): timetable = get_object_or_404(Timetable, slug=timetable_slug) group = get_object_or_404(Group, slug=group_slug, timetable=timetable) - courses = Course.objects.get_courses_for_group(group, timetable=timetable, begin__gte=start, begin__lt=end) + courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) last_update = LastUpdate.objects.get(timetable=timetable, week=week, year=year) grouped_courses = group_courses(courses) -- cgit v1.2.1