fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
translation update
[wolnelektury.git]
/
src
/
api
/
handlers.py
diff --git
a/src/api/handlers.py
b/src/api/handlers.py
index
b81afda
..
827cd7c
100644
(file)
--- a/
src/api/handlers.py
+++ b/
src/api/handlers.py
@@
-13,6
+13,7
@@
from sorl.thumbnail import default
from catalogue.forms import BookImportForm
from catalogue.models import Book, Tag, BookMedia, Fragment, Collection
from catalogue.forms import BookImportForm
from catalogue.models import Book, Tag, BookMedia, Fragment, Collection
+from catalogue.models.tag import prefetch_relations
from picture.models import Picture
from picture.forms import PictureImportForm
from picture.models import Picture
from picture.forms import PictureImportForm
@@
-206,8
+207,9
@@
class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
if daisy:
books = books.filter(media__type='daisy').distinct()
if daisy:
books = books.filter(media__type='daisy').distinct()
- books = books.only('slug', 'title', 'cover')
-
+ books = books.only('slug', 'title', 'cover', 'cover_thumb')
+ for category in book_tag_categories:
+ books = prefetch_relations(books, category)
if books:
return books
else:
if books:
return books
else:
@@
-251,7
+253,7
@@
def _tags_getter(category):
def _tag_getter(category):
@classmethod
def get_tag(cls, book):
def _tag_getter(category):
@classmethod
def get_tag(cls, book):
- return
', '.join(book.tags.filter(category=category).values_list('name', flat=True)
)
+ return
book.tag_unicode(category
)
return get_tag
return get_tag