diff options
author | Alban Gruin | 2017-09-29 14:33:55 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-29 14:33:55 +0200 |
commit | a30de7e84c7c7208f76178586befe5374cd1e02d (patch) | |
tree | 9fba9325007d62d2c9081f1ff23b0d4fc56da7eb | |
parent | 1d5068de5e4babb8c2c969c626fd1d8b53bc28ea (diff) |
Affichage des cours des groupes enfants si le groupe demandé en possède
-rw-r--r-- | models.py | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -144,11 +144,17 @@ class Room(models.Model): class CourseManager(Manager): def get_courses_for_group(self, group, **criteria): + groups_criteria = [] + if group.subgroup is not None: + groups_criteria.append(Q(groups__subgroup__isnull=True) | \ + Q(groups__subgroup=group.subgroup)) + if group.td is not None: + groups_criteria.append(Q(groups__td__isnull=True) | Q(groups__td=group.td)) + if group.tp is not None: + groups_criteria.append(Q(groups__tp__isnull=True) | Q(groups__tp=group.tp)) + 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), - Q(groups__subgroup__isnull=True) | \ - Q(groups__subgroup=group.subgroup), + .filter(*groups_criteria, groups__mention=group.mention, timetable=group.timetable, **criteria) \ .order_by("begin") |