X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8830e06ad0b466c40747540b5122e6825114a90a..9249e6ddc35e7cc7077fa5035fbc27397fbb70a9:/apps/wiki/models.py?ds=sidebyside diff --git a/apps/wiki/models.py b/apps/wiki/models.py index 9eb77a5c..28fdab8b 100644 --- a/apps/wiki/models.py +++ b/apps/wiki/models.py @@ -157,7 +157,7 @@ class Chunk(dvcs_models.Document): book = models.ForeignKey(Book, editable=False) number = models.IntegerField() slug = models.SlugField() - comment = models.CharField(max_length=255) + comment = models.CharField(max_length=255, blank=True) class Meta: unique_together = [['book', 'number'], ['book', 'slug']] @@ -177,8 +177,13 @@ class Chunk(dvcs_models.Document): return cls.objects.get(book__slug=slug, slug=chunk) def pretty_name(self): - return "%s, %s (%d/%d)" % (self.book.title, self.comment, - self.number, len(self.book)) + title = self.book.title + if self.comment: + title += ", %s" % self.comment + count = len(self.book) + if count > 1: + title += " (%d/%d)" % (self.number, len(self.book)) + return title def split(self, slug, comment='', creator=None): """ Create an empty chunk after this one """