diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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() |