X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b9bf77dc8f2d4b1b64bd7a29730bec3e3f885a6e..9e41863c3cff14cbbc65b783ee57120fb59fa22c:/apps/catalogue/models.py diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index afc241ddd..a5b0ebf0c 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -481,7 +481,7 @@ class Book(models.Model): formats = [] # files generated during publication if self.has_media("html"): - formats.append(u'%s' % (reverse('book_text', [self.fileid()]), _('Read online'))) + formats.append(u'%s' % (reverse('book_text', args=[self.fileid()]), _('Read online'))) if self.has_media("pdf"): formats.append(u'PDF' % self.get_media('pdf').url) if self.has_media("mobi"): @@ -503,6 +503,23 @@ class Book(models.Model): cache.set(cache_key, short_html, CACHE_FOREVER) return mark_safe(short_html) + def mini_box(self): + if self.id: + cache_key = "Book.mini_boxs/%d" % (self.id, ) + short_html = cache.get(cache_key) + else: + short_html = None + + if short_html is None: + authors = self.tags.filter(category='author') + + short_html = unicode(render_to_string('catalogue/book_mini_box.html', + {'book': self, 'authors': authors, 'STATIC_URL': settings.STATIC_URL})) + + if self.id: + cache.set(cache_key, short_html, CACHE_FOREVER) + return mark_safe(short_html) + @property def root_ancestor(self): """ returns the oldest ancestor """