X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1412fa8813203d127b60add381af5d4c48a4b4a0..909fd9ccd6f636cc512328dea596902d42d0f55c:/src/catalogue/models/book.py?ds=inline diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index b0c63a0ec..69d71aef2 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -81,6 +81,9 @@ class Book(models.Model): parent = models.ForeignKey('self', blank=True, null=True, related_name='children') ancestor = models.ManyToManyField('self', blank=True, editable=False, related_name='descendant', symmetrical=False) + cached_author = models.CharField(blank=True, max_length=240, db_index=True) + has_audience = models.BooleanField(default=False) + objects = models.Manager() tagged = managers.ModelTaggedItemManager(Tag) tags = managers.TagDescriptor(Tag) @@ -120,7 +123,7 @@ class Book(models.Model): return ', '.join(self.tags.filter(category=category).values_list('name', flat=True)) def author_unicode(self): - return self.tag_unicode('author') + return self.cached_author def translator(self): translators = self.extra_info.get('translators') @@ -145,6 +148,9 @@ class Book(models.Model): author = u'' self.sort_key_author = author + self.cached_author = self.tag_unicode('author') + self.has_audience = 'audience' in self.extra_info + ret = super(Book, self).save(force_insert, force_update, **kwargs) return ret