return MEDIA_BASE + book.cover_api_thumb.url if book.cover_api_thumb else ''
@classmethod
- def cover_source_image(cls, book):
- url = book.cover_source()
- return url.rstrip('/') + '/file/'
+ def simple_cover(cls, book):
+ return MEDIA_BASE + book.simple_cover.url if book.simple_cover else ''
class BookDetailHandler(BaseHandler, BookDetails):
"""
allowed_methods = ['GET']
fields = ['title', 'parent', 'children'] + Book.formats + [
- 'media', 'url', 'cover', 'cover_thumb', 'simple_thumb', 'fragment_data'] + [
+ 'media', 'url', 'cover', 'cover_thumb', 'simple_thumb', 'simple_cover', 'fragment_data'] + [
category_plural[c] for c in book_tag_categories]
@piwik_track
class FilterBooksHandler(AnonymousBooksHandler):
fields = book_tag_categories + [
- 'href', 'title', 'url', 'cover', 'cover_thumb', 'simple_thumb', 'slug', 'key', 'cover_source_image']
+ 'href', 'title', 'url', 'cover', 'cover_thumb', 'simple_thumb', 'slug', 'key']
def read(self, request):
key_sep = '$'
return WLNoBoxCover(wldoc.book_info, height=500).output_file()
+@BuildEbook.register('simple_cover')
+@task(ignore_result=True)
+class BuildSimpleCover(BuildEbook):
+ @classmethod
+ def transform(cls, wldoc, fieldfile):
+ from librarian.cover import WLNoBoxCover
+ return WLNoBoxCover(wldoc.book_info, height=1000).output_file()
+
+
# not used, but needed for migrations
class OverwritingFieldFile(FieldFile):
"""
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import catalogue.fields
+import catalogue.models.book
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0020_book_cover_api_thumb'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='book',
+ name='simple_cover',
+ field=catalogue.fields.EbookField(b'simple_cover', max_length=255, upload_to=catalogue.models.book.UploadToPath(b'book/cover_simple/%s.jpg'), null=True, verbose_name='cover for mobile app', blank=True),
+ ),
+ migrations.AlterField(
+ model_name='book',
+ name='cover_api_thumb',
+ field=catalogue.fields.EbookField(b'cover_api_thumb', max_length=255, upload_to=catalogue.models.book.UploadToPath(b'book/cover_api_thumb/%s.jpg'), null=True, verbose_name='cover thumbnail for mobile app', blank=True),
+ ),
+ ]
_cover_upload_to = UploadToPath('book/cover/%s.jpg')
_cover_thumb_upload_to = UploadToPath('book/cover_thumb/%s.jpg')
-_cover_api_thumb_opload_to = UploadToPath('book/cover_api_thumb/%s.jpg')
+_cover_api_thumb_upload_to = UploadToPath('book/cover_api_thumb/%s.jpg')
+_simple_cover_upload_to = UploadToPath('book/cover_simple/%s.jpg')
def _ebook_upload_to(upload_path):
upload_to=_cover_thumb_upload_to,
max_length=255)
cover_api_thumb = EbookField(
- 'cover_api_thumb', _('cover thumbnail for API'),
+ 'cover_api_thumb', _('cover thumbnail for mobile app'),
null=True, blank=True,
- upload_to=_cover_api_thumb_opload_to,
+ upload_to=_cover_api_thumb_upload_to,
+ max_length=255)
+ simple_cover = EbookField(
+ 'simple_cover', _('cover for mobile app'),
+ null=True, blank=True,
+ upload_to=_simple_cover_upload_to,
max_length=255)
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
book.cover.build_delay()
book.cover_thumb.build_delay()
book.cover_api_thumb.build_delay()
+ book.simple_cover.build_delay()
# Build HTML and ebooks.
book.html_file.build_delay()
self.cover.build_delay()
self.cover_thumb.build_delay()
self.cover_api_thumb.build_delay()
+ self.simple_cover.build_delay()
for format_ in constants.EBOOK_FORMATS_WITH_COVERS:
if format_ not in app_settings.DONT_BUILD:
getattr(self, '%s_file' % format_).build_delay()