- self._short_html = unicode(render_to_string('catalogue/book_short.html',
- {'book': self, 'tags': tags, 'formats': formats}))
- self.save()
- return mark_safe(self._short_html)
+ formats = [mark_safe(format) for format in formats]
+
+ setattr(self, key, unicode(render_to_string('catalogue/book_short.html',
+ {'book': self, 'tags': tags, 'formats': formats})))
+ self.save(reset_short_html=False)
+ return mark_safe(getattr(self, key))
+
+ def save(self, force_insert=False, force_update=False, reset_short_html=True):
+ if reset_short_html:
+ # Reset _short_html during save
+ for key in filter(lambda x: x.startswith('_short_html'), self.__dict__):
+ self.__setattr__(key, '')
+
+ book = super(Book, self).save(force_insert, force_update)
+
+ if self.mp3_file:
+ print self.mp3_file, self.mp3_file.path
+ extra_info = self.get_extra_info_value()
+ extra_info.update(self.get_mp3_info())
+ self.set_extra_info_value(extra_info)
+ book = super(Book, self).save(force_insert, force_update)
+
+ return book