diff options
author | Alban Gruin | 2018-01-16 20:31:20 +0100 |
---|---|---|
committer | Alban Gruin | 2018-01-16 20:31:20 +0100 |
commit | 8f9c5eb32c6cf27aa84d1cbf14b7aaaa00acc0b9 (patch) | |
tree | b5ca91fca9f934118de754f8ecd46c93bbde6dcc /models.py | |
parent | 81cb9b8c6a96fa8529c6d7f6ca55dfd56a1f2e5d (diff) |
Utilisation des valeurs par défaut de reduce()
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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), |