From 7f146b306760e1a70e8e1a79d58fc967d05fe194 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 25 Nov 2017 13:30:42 +0100 Subject: Suppression de get_relevant_groups --- models.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/models.py b/models.py index 40849c6..9838377 100644 --- a/models.py +++ b/models.py @@ -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() -- cgit v1.2.1