aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-01 15:17:35 +0100
committerAlban Gruin2017-11-01 15:17:35 +0100
commit912f3cca24da9d870aa191348fef901adcd55b7d (patch)
tree2566aff8bb231c005d9799f611e89f820b193ba7 /models.py
parentbafa5f07a4e1b5c2cc2bb234ad2f12929a983025 (diff)
get_parents() sélectionne aussi les groupes enfants dont le
sous-groupe commence par la même chaîne que celui du groupe passé en paramètre. Correction cosmétique du code.
Diffstat (limited to 'models.py')
-rw-r--r--models.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/models.py b/models.py
index c546737..c3118a3 100644
--- a/models.py
+++ b/models.py
@@ -71,7 +71,7 @@ class Timetable(SlugModel):
class GroupManager(Manager):
def get_parents(self, group):
- groups_criteria = Q(subgroup__isnull=True) | \
+ groups_criteria = Q(subgroup__isnull=True) | Q(subgroup__startswith=group.subgroup) | \
reduce(lambda x, y: x | y,
[Q(subgroup=group.subgroup[:i])
for i in range(1, len(group.subgroup) + 1)])
@@ -80,7 +80,7 @@ class GroupManager(Manager):
timetable=group.timetable)
def get_relevant_groups(self, timetable, *args, **criteria):
- sub = Group.objects.filter(timetable=timetable,mention=OuterRef("mention"),
+ sub = Group.objects.filter(timetable=timetable, mention=OuterRef("mention"),
subgroup__startswith=OuterRef("subgroup")) \
.order_by().values("mention").annotate(c=Count("*")).values("c")