aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-24 21:32:14 +0100
committerAlban Gruin2017-11-24 21:32:14 +0100
commit33d71f450619c8f0145b9c2b0516966e7b4f4ea5 (patch)
tree707e7efb34d0ce4c210f4db8b4dd192558e82e66 /models.py
parentdaa18b5fdc0284202f0efeefe562db2edc9f191f (diff)
parentd9b78963e8526b803f1165c79ae2f97c6a36016b (diff)
Merge branch 'stable/0.11.z' into prod/pa1ch/0.11.z
Diffstat (limited to 'models.py')
-rw-r--r--models.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/models.py b/models.py
index 6d06793..14270cf 100644
--- a/models.py
+++ b/models.py
@@ -83,9 +83,10 @@ class GroupManager(Manager):
timetable=group.timetable)
def get_relevant_groups(self, timetable, *args, **criteria):
- sub = self.get_queryset().filter(timetable=timetable, mention=OuterRef("mention"),
- subgroup__startswith=OuterRef("subgroup")) \
- .order_by().values("mention").annotate(c=Count("*")).values("c")
+ sub = self.get_queryset().filter(timetable=timetable,
+ mention__startswith=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())) \
@@ -115,7 +116,8 @@ class Group(models.Model):
self.subgroup.startswith(subgroup)
return self.timetable.id == timetable_id and \
- self.mention.startswith(mention) and \
+ (self.mention.startswith(mention) or \
+ mention.startswith(self.mention)) and \
subgroup_corresponds
@property