+ _tag_counter = JSONField(editable=False, default='')
+ _theme_counter = JSONField(editable=False, default='')
+
+ class AlreadyExists(Exception):
+ pass
+
+ class Meta:
+ ordering = ('title',)
+ verbose_name = _('book')
+ verbose_name_plural = _('books')
+
+ def __unicode__(self):
+ return self.title
+
+ def save(self, force_insert=False, force_update=False, reset_short_html=True, refresh_mp3=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 refresh_mp3 and 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
+
+ @permalink
+ def get_absolute_url(self):
+ return ('catalogue.views.book_detail', [self.slug])
+