aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2018-01-16 20:31:20 +0100
committerAlban Gruin2018-01-16 20:31:20 +0100
commit8f9c5eb32c6cf27aa84d1cbf14b7aaaa00acc0b9 (patch)
treeb5ca91fca9f934118de754f8ecd46c93bbde6dcc
parent81cb9b8c6a96fa8529c6d7f6ca55dfd56a1f2e5d (diff)
Utilisation des valeurs par défaut de reduce()
-rw-r--r--models.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/models.py b/models.py
index 363cf33..56c1845 100644
--- a/models.py
+++ b/models.py
@@ -93,12 +93,10 @@ class Timetable(SlugModel):
class GroupManager(Manager):
def get_parents(self, group):
- groups_criteria = Q(subgroup="")
-
- if len(group.subgroup) != 0:
- groups_criteria |= reduce(lambda x, y: x | y,
- [Q(subgroup=group.subgroup[:i])
- for i in range(1, len(group.subgroup) + 1)])
+ groups_criteria = reduce(lambda x, y: x | y,
+ [Q(subgroup=group.subgroup[:i])
+ for i in range(1, len(group.subgroup) + 1)],
+ Q(subgroup=""))
return self.get_queryset().filter(groups_criteria,
Q(semester=None) | Q(semester=group.semester),