X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/572ee91a188114e383712eac2426dab3bcef6c00..9d7d8b6bf3dcc7b8322bc4d636d793fe46c106e8:/src/catalogue/models/book.py?ds=sidebyside diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 6fcf181e0..375c79a8e 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -38,9 +38,9 @@ bofh_storage = BofhFileSystemStorage() class Book(models.Model): """Represents a book imported from WL-XML.""" title = models.CharField('tytuł', max_length=32767) - sort_key = models.CharField('klucz sortowania', max_length=120, db_index=True, editable=False) + sort_key = models.CharField('klucz sortowania', max_length=120, db_index=True, db_collation='C', editable=False) sort_key_author = models.CharField( - 'klucz sortowania wg autora', max_length=120, db_index=True, editable=False, default='') + 'klucz sortowania wg autora', max_length=120, db_index=True, db_collation='C', editable=False, default='') slug = models.SlugField('slug', max_length=120, db_index=True, unique=True) common_slug = models.SlugField('wspólny slug', max_length=120, db_index=True) language = models.CharField('kod języka', max_length=3, db_index=True, default=app_settings.DEFAULT_LANGUAGE) @@ -98,8 +98,8 @@ class Book(models.Model): translators = models.ManyToManyField(Tag, blank=True) narrators = models.ManyToManyField(Tag, blank=True, related_name='narrated') has_audio = models.BooleanField(default=False) - read_time = models.FloatField(blank=True, null=True) - pages = models.FloatField(blank=True, null=True) + read_time = models.IntegerField(blank=True, null=True) + pages = models.IntegerField(blank=True, null=True) html_built = django.dispatch.Signal() published = django.dispatch.Signal() @@ -814,10 +814,10 @@ class Book(models.Model): def update_stats(self): stats = self.wldocument2().get_statistics()['total'] - self.pages = ( - stats['verses_with_fn'] / 30 + - stats['chars_out_verse_with_fn'] / 1800) - self.read_time = self.get_time() + self.pages = round( + stats.get('verses_with_fn', 0) / 30 + + stats.get('chars_out_verse_with_fn', 0) / 1800) + self.read_time = round(self.get_time()) self.save(update_fields=['pages', 'read_time']) if self.parent is not None: self.parent.update_stats()