diff options
author | Alban Gruin | 2017-11-07 20:36:20 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-07 20:36:20 +0100 |
commit | 111c0fcba0692d175e42258f9aa814de6a2bb1ff (patch) | |
tree | 2f12fe1325e0dfddb26460349b3e0fcf1e9288e8 /models.py | |
parent | ffffd9842dbaba0b0e89ff5f434f45792e2b73b6 (diff) | |
parent | 5c2bc37ed5d8353ea0ee1d9e5f852a1f39ac235f (diff) |
Merge branch 'stable/0.11.z' into prod/pa1ch/0.11.zv0.11.1-pa1ch
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -71,7 +71,7 @@ class Timetable(SlugModel): class GroupManager(Manager): def get_parents(self, group): - groups_criteria = Q(subgroup__isnull=True) | Q(subgroup__startswith=group.subgroup) | \ + 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)]) @@ -99,8 +99,7 @@ class Group(models.Model): verbose_name="emploi du temps") mention = models.CharField(max_length=128) - subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", - null=True) + subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", default="") slug = models.SlugField(max_length=64, default="") @@ -129,6 +128,9 @@ class Group(models.Model): self.slug = slugify(self.name) self.mention, self.subgroup = parse_group(self.name) + if self.subgroup is None: + self.subgroup = "" + super(Group, self).save() |