diff options
author | Alban Gruin | 2017-11-25 13:30:42 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-25 13:30:42 +0100 |
commit | 7f146b306760e1a70e8e1a79d58fc967d05fe194 (patch) | |
tree | a46dd2dfdd9a343cac2145605c81e604620adec1 | |
parent | b99dbd566fba7f3c18d3832edeb8e019abcc8c87 (diff) |
Suppression de get_relevant_groups
-rw-r--r-- | models.py | 14 |
1 files changed, 1 insertions, 13 deletions
@@ -16,8 +16,7 @@ from functools import reduce from django.db import models -from django.db.models import Count, Manager, Q, Subquery, Value -from django.db.models.expressions import OuterRef +from django.db.models import Count, Manager, Q from django.db.models.functions import ExtractWeek, ExtractYear from django.utils import timezone from django.utils.text import slugify @@ -82,17 +81,6 @@ class GroupManager(Manager): return self.get_queryset().filter(groups_criteria, mention=group.mention, timetable=group.timetable) - def get_relevant_groups(self, timetable, *args, **criteria): - sub = self.get_queryset().filter(timetable=timetable, - mention__startswith=OuterRef("mention"), - subgroup__startswith=OuterRef("subgroup")) \ - .annotate(v=Value(0)).values("v") \ - .annotate(c=Count("v")).values("c") # fuck Count() - - return self.get_queryset().filter(*args, timetable=timetable, hidden=False, **criteria) \ - .annotate(nbsub=Subquery(sub, output_field=models.IntegerField())) \ - .filter(Q(nbsub=1) | Q(nbsub__isnull=True)).order_by("name") - class Group(models.Model): objects = GroupManager() |