diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -65,6 +65,13 @@ class Timetable(SlugModel): class GroupManager(Manager): + def get_relevant_children(self, group): + parent_in = self.get_queryset().filter(parent=group) + return self.get_queryset().filter(Q(parent=group) | Q(parent__in=parent_in)) \ + .annotate(children_count=Count("children")) \ + .filter(children_count=0) \ + .order_by("name") + def get_relevant_groups(self, *args, **criteria): return self.get_queryset().filter(*args, **criteria) \ .annotate(children_count=Count("children")) \ |