diff options
author | Alban Gruin | 2017-11-06 08:26:46 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-06 08:26:46 +0100 |
commit | 60b2ceaa43d01e34514f3e68f45585619807d1cf (patch) | |
tree | cf8763dfd9bbbe48a5383a5f49ca07437916c7a6 /models.py | |
parent | 771f4ebb8f1e27212bfce413ea664a73c7a86965 (diff) | |
parent | 37a95855076035470e7484804ed48b779ed22277 (diff) |
Merge branch 'dev/alban'
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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,13 +80,13 @@ class GroupManager(Manager): timetable=group.timetable) def get_relevant_groups(self, timetable, *args, **criteria): - sub = Group.objects.filter(timetable=timetable,mention=OuterRef("mention"), + sub = self.get_queryset().filter(timetable=timetable, mention=OuterRef("mention"), subgroup__startswith=OuterRef("subgroup")) \ .order_by().values("mention").annotate(c=Count("*")).values("c") return self.get_queryset().filter(*args, timetable=timetable, hidden=False, **criteria) \ .annotate(nbsub=Subquery(sub, output_field=models.IntegerField())) \ - .filter(nbsub=1).order_by("name") + .filter(Q(nbsub=1) | Q(nbsub__isnull=True)).order_by("name") class Group(models.Model): |