Fix page table integrity

This commit is contained in:
Skia 2015-11-24 14:00:41 +01:00
parent ce8ceb80d6
commit 7b093f6fbd
1 changed files with 4 additions and 0 deletions

View File

@ -120,6 +120,7 @@ class Page(models.Model):
query, but don't rely on it when playing with a Page object, use get_full_name() instead!
"""
name = models.CharField(_('page name'), max_length=30, blank=False)
# TODO: move title and content to PageRev class with a OneToOne field
title = models.CharField(_("page title"), max_length=255, blank=True)
content = models.TextField(_("page content"), blank=True)
revision = models.PositiveIntegerField(_("current revision"), default=1)
@ -163,7 +164,10 @@ class Page(models.Model):
self.full_clean()
# This reset the full_name just before saving to maintain a coherent field quicker for queries than the
# recursive method
# It also update all the children to maintain correct names
self.full_name = self.get_full_name()
for c in self.children.all():
c.save()
super(Page, self).save(*args, **kwargs)
def __str__(self):