from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _
import jsonfield
from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _
import jsonfield
from catalogue import constants
from catalogue.fields import EbookField
from catalogue.models import Tag, Fragment, BookMedia
from catalogue import constants
from catalogue.fields import EbookField
from catalogue.models import Tag, Fragment, BookMedia
-from catalogue.utils import create_zip, split_tags, book_upload_path, related_tag_name
+from catalogue.utils import create_zip, split_tags, related_tag_name
from catalogue import app_settings
from catalogue import tasks
from newtagging import managers
from catalogue import app_settings
from catalogue import tasks
from newtagging import managers
# files generated during publication
cover = EbookField('cover', _('cover'),
# files generated during publication
cover = EbookField('cover', _('cover'),
- upload_to=book_upload_path('jpg'), null=True, blank=True)
+ null=True, blank=True,
+ upload_to=lambda i, n: 'book/cover/%s.jpg' % i.slug,
+ storage=bofh_storage, max_length=255)
- cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
- upload_to=book_upload_path('th.jpg'), null=True, blank=True)
+ cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
+ null=True, blank=True,
+ upload_to=lambda i, n: 'book/cover_thumb/%s.jpg' % i.slug,
+ max_length=255)
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
if self.has_media(type_):
if type_ in Book.formats:
return getattr(self, "%s_file" % type_)
if self.has_media(type_):
if type_ in Book.formats:
return getattr(self, "%s_file" % type_)
rel_info = book.related_info()
names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
for tag in rel_info['tags'].get('author', ())]
rel_info = book.related_info()
names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
for tag in rel_info['tags'].get('author', ())]
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
# eliminate descendants
l_tags = Tag.objects.filter(category='book',
slug__in=[book.book_tag_slug() for book in parents.iterator()])
# eliminate descendants
l_tags = Tag.objects.filter(category='book',
slug__in=[book.book_tag_slug() for book in parents.iterator()])
'title', 'parent', 'slug')
if filter:
books = books.filter(filter).distinct()
'title', 'parent', 'slug')
if filter:
books = books.filter(filter).distinct()
- upload_to=book_upload_path(format_),
- blank=True, default='').contribute_to_class(Book, field_name)
+ upload_to=upload_to,
+ storage=bofh_storage,
+ max_length=255,
+ blank=True,
+ default=''
+ ).contribute_to_class(Book, field_name)