aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-27 21:29:24 +0100
committerAlban Gruin2017-01-27 21:29:24 +0100
commit73fe8ff6ac3945696a24a31c150dc82f74c1389b (patch)
tree617a27c31dfd2f57959ff23684a1909beb1bcf73 /models.py
parent70869e67c13e463c03dd6e6a618604de7f85e2d8 (diff)
DJANGO FFS LAISSE MOI FAIRE UN GROUP BY AVEC TON ORM BORDEL
Diffstat (limited to 'models.py')
-rw-r--r--models.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/models.py b/models.py
index 18e0246..5e5ee1b 100644
--- a/models.py
+++ b/models.py
@@ -108,6 +108,9 @@ 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")
+
class Course(models.Model):
objects = CourseManager()