From 47624b1e6973e8a4394d9985a30e23db7fdfb096 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 27 Jan 2017 21:36:26 +0100 Subject: Ajout d'un critère de date --- models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index 5e5ee1b..981d8fb 100644 --- a/models.py +++ b/models.py @@ -108,8 +108,8 @@ class CourseManager(models.Manager): 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") - def get_weeks(self): - return self.get_queryset().raw("select edt_course.id, cast(strftime('%%W', begin) as integer) as week, cast(strftime('%%Y', begin) as integer) as year, edt_group.name, edt_group.timetable_id, edt_group.mention, edt_group.subgroup, edt_group.td, edt_group.tp, edt_group.slug, edt_group.id as group_id from edt_course inner join edt_course_groups on (edt_course.id = edt_course_groups.course_id) inner join edt_group on (edt_course_groups.group_id = edt_group.id) group by group_id, week, year order by group_id, year, week") + def get_weeks(self, date): + return self.get_queryset().raw("select edt_course.id, cast(strftime('%%W', begin) as integer) as week, cast(strftime('%%Y', begin) as integer) as year, edt_group.name, edt_group.timetable_id, edt_group.mention, edt_group.subgroup, edt_group.td, edt_group.tp, edt_group.slug, edt_group.id as group_id from edt_course inner join edt_course_groups on (edt_course.id = edt_course_groups.course_id) inner join edt_group on (edt_course_groups.group_id = edt_group.id) where begin >= %s group by group_id, week, year order by group_id, year, week", [date]) class Course(models.Model): -- cgit v1.2.1