user = models.ForeignKey(User, blank=True, null=True)
book_count = models.IntegerField(_('book count'), default=0, blank=False, null=False)
user = models.ForeignKey(User, blank=True, null=True)
book_count = models.IntegerField(_('book count'), default=0, blank=False, null=False)
_short_html = models.TextField(_('short HTML'), editable=False)
parent_number = models.IntegerField(_('parent number'), default=0)
extra_info = JSONField(_('extra information'))
_short_html = models.TextField(_('short HTML'), editable=False)
parent_number = models.IntegerField(_('parent number'), default=0)
extra_info = JSONField(_('extra information'))
return mark_safe(self._short_html)
else:
tags = self.tags.filter(~Q(category__in=('set', 'theme', 'book')))
return mark_safe(self._short_html)
else:
tags = self.tags.filter(~Q(category__in=('set', 'theme', 'book')))
- formats.append(u'<a href="%s">Plik TXT</a>' % self.txt_file.url)
+ formats.append(u'<a href="%s">TXT</a>' % self.txt_file.url)
+ if self.mp3_file:
+ formats.append(u'<a href="%s">MP3</a>' % self.mp3_file.url)
+ if self.ogg_file:
+ formats.append(u'<a href="%s">OGG</a>' % self.ogg_file.url)
+
+ formats = [mark_safe(format) for format in formats]
self._short_html = unicode(render_to_string('catalogue/book_short.html',
{'book': self, 'tags': tags, 'formats': formats}))
self._short_html = unicode(render_to_string('catalogue/book_short.html',
{'book': self, 'tags': tags, 'formats': formats}))
- book.xml_file.save('%s.xml' % book.slug, File(file(xml_file)), save=False)
+ if not isinstance(xml_file, File):
+ xml_file = File(file(xml_file))
+ book.xml_file.save('%s.xml' % book.slug, xml_file, save=False)
html_file = NamedTemporaryFile()
if html.transform(book.xml_file.path, html_file):
html_file = NamedTemporaryFile()
if html.transform(book.xml_file.path, html_file):
for tag in self.book.tags if tag.category == 'author']
self._short_html = unicode(render_to_string('catalogue/fragment_short.html',
for tag in self.book.tags if tag.category == 'author']
self._short_html = unicode(render_to_string('catalogue/fragment_short.html',