aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-07 20:36:20 +0100
committerAlban Gruin2017-11-07 20:36:20 +0100
commit111c0fcba0692d175e42258f9aa814de6a2bb1ff (patch)
tree2f12fe1325e0dfddb26460349b3e0fcf1e9288e8 /models.py
parentffffd9842dbaba0b0e89ff5f434f45792e2b73b6 (diff)
parent5c2bc37ed5d8353ea0ee1d9e5f852a1f39ac235f (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.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/models.py b/models.py
index 3af1c06..0804a38 100644
--- a/models.py
+++ b/models.py
@@ -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()