diff options
author | Alban Gruin | 2017-11-16 19:01:27 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-16 19:01:27 +0100 |
commit | daa18b5fdc0284202f0efeefe562db2edc9f191f (patch) | |
tree | fd7fe03e3accb301a6111770220a6e1e0fe4746d /models.py | |
parent | 111c0fcba0692d175e42258f9aa814de6a2bb1ff (diff) | |
parent | b2c14a2db9b79dca007db5e32aefbf76ebd05fd1 (diff) |
Merge branch 'stable/0.11.z' into prod/pa1ch/0.11.zv0.11.2-pa1ch
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -57,7 +57,8 @@ class Timetable(SlugModel): url = models.URLField(max_length=255, verbose_name="URL") slug = models.SlugField(max_length=64, default="") - last_update_date = models.DateTimeField(verbose_name="dernière mise à jour Celcat", null=True) + last_update_date = models.DateTimeField(verbose_name="dernière mise à jour Celcat", + null=True, blank=True) def __str__(self): return self.year.name + " " + self.name @@ -71,10 +72,12 @@ class Timetable(SlugModel): class GroupManager(Manager): def get_parents(self, group): - groups_criteria = Q(subgroup="") | Q(subgroup__startswith=group.subgroup) | \ - reduce(lambda x, y: x | y, - [Q(subgroup=group.subgroup[:i]) - for i in range(1, len(group.subgroup) + 1)]) + groups_criteria = Q(subgroup="") | Q(subgroup__startswith=group.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)]) return self.get_queryset().filter(groups_criteria, mention=group.mention, timetable=group.timetable) |