aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-25 13:30:42 +0100
committerAlban Gruin2017-11-25 13:30:42 +0100
commit7f146b306760e1a70e8e1a79d58fc967d05fe194 (patch)
treea46dd2dfdd9a343cac2145605c81e604620adec1 /models.py
parentb99dbd566fba7f3c18d3832edeb8e019abcc8c87 (diff)
Suppression de get_relevant_groups
Diffstat (limited to 'models.py')
-rw-r--r--models.py14
1 files changed, 1 insertions, 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()