fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Django 1.6 and some cleaning.
[wolnelektury.git]
/
apps
/
catalogue
/
models
/
book.py
diff --git
a/apps/catalogue/models/book.py
b/apps/catalogue/models/book.py
index
3c50a96
..
b9441c3
100644
(file)
--- a/
apps/catalogue/models/book.py
+++ b/
apps/catalogue/models/book.py
@@
-44,6
+44,9
@@
class Book(models.Model):
cover = EbookField('cover', _('cover'),
upload_to=book_upload_path('jpg'), null=True, blank=True)
cover = EbookField('cover', _('cover'),
upload_to=book_upload_path('jpg'), null=True, blank=True)
+ # Cleaner version of cover for thumbs
+ cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
+ upload_to=book_upload_path('th.jpg'), null=True, blank=True)
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
@@
-319,6
+322,7
@@
class Book(models.Model):
tasks.fix_tree_tags.delay(book)
if 'cover' not in dont_build:
book.cover.build_delay()
tasks.fix_tree_tags.delay(book)
if 'cover' not in dont_build:
book.cover.build_delay()
+ book.cover_thumb.build_delay()
# No saves behind this point.
# No saves behind this point.
@@
-401,6
+405,7
@@
class Book(models.Model):
if not self.cover_info(inherit=False):
if 'cover' not in app_settings.DONT_BUILD:
self.cover.build_delay()
if not self.cover_info(inherit=False):
if 'cover' not in app_settings.DONT_BUILD:
self.cover.build_delay()
+ self.cover_thumb.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()
for format_ in constants.EBOOK_FORMATS_WITH_COVERS:
if format_ not in app_settings.DONT_BUILD:
getattr(self, '%s_file' % format_).build_delay()
@@
-516,8
+521,6
@@
class Book(models.Model):
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', ())]
- import logging
- logging.info("%s, %s" % (book.slug, unicode(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']]
@@
-540,7
+543,7
@@
class Book(models.Model):
"""
# get relevant books and their tags
objects = cls.tagged.with_all(tags)
"""
# get relevant books and their tags
objects = cls.tagged.with_all(tags)
- parents = objects.
filter(html_file=''
).only('slug')
+ parents = objects.
exclude(children=None
).only('slug')
# 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()])