aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/models.py b/models.py
index 53bcef7..1843a9f 100644
--- a/models.py
+++ b/models.py
@@ -92,6 +92,18 @@ class Group(models.Model):
self.slug = slugify(self.name)
self.mention, self.subgroup, self.td, self.tp = parse_group(self.name)
+
+ group_content_list = [self.mention, self.subgroup, self.td, self.tp]
+ group_content_keys = ("mention", "subgroup", "td", "tp")
+ for i in range(len(group_content_list))[::-1]:
+ if group_content_list[i] is not None:
+ group_content_list[i] = None
+ break
+
+ if group_content_list[1] is not None:
+ group_content = dict(zip(group_content_keys, group_content_list))
+ self.parent_group_id = Group.objects.filter(**group_content).first().id
+
super(Group, self).save()