fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
First obvious accessibility fixes.
[wolnelektury.git]
/
apps
/
api
/
handlers.py
diff --git
a/apps/api/handlers.py
b/apps/api/handlers.py
index
437b3be
..
dbe905b
100644
(file)
--- a/
apps/api/handlers.py
+++ b/
apps/api/handlers.py
@@
-12,6
+12,7
@@
from django.core.cache import get_cache
from django.core.urlresolvers import reverse
from piston.handler import AnonymousBaseHandler, BaseHandler
from piston.utils import rc
from django.core.urlresolvers import reverse
from piston.handler import AnonymousBaseHandler, BaseHandler
from piston.utils import rc
+from sorl.thumbnail import default
from api.helpers import timestamp
from api.models import Deleted
from api.helpers import timestamp
from api.models import Deleted
@@
-134,6
+135,11
@@
class BookDetails(object):
def cover(cls, book):
return MEDIA_BASE + book.cover.url if book.cover else ''
def cover(cls, book):
return MEDIA_BASE + book.cover.url if book.cover else ''
+ @classmethod
+ def cover_thumb(cls, book):
+ return MEDIA_BASE + default.backend.get_thumbnail(
+ book.cover, "139x193").url if book.cover else ''
+
class BookDetailHandler(BaseHandler, BookDetails):
class BookDetailHandler(BaseHandler, BookDetails):
@@
-143,7
+149,7
@@
class BookDetailHandler(BaseHandler, BookDetails):
"""
allowed_methods = ['GET']
fields = ['title', 'parent', 'children'] + Book.formats + [
"""
allowed_methods = ['GET']
fields = ['title', 'parent', 'children'] + Book.formats + [
- 'media', 'url', 'cover'] + [
+ 'media', 'url', 'cover'
, 'cover_thumb'
] + [
category_plural[c] for c in book_tag_categories]
@piwik_track
category_plural[c] for c in book_tag_categories]
@piwik_track
@@
-192,9
+198,9
@@
class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
if top_level:
books = books.filter(parent=None)
if audiobooks:
if top_level:
books = books.filter(parent=None)
if audiobooks:
- books = books.filter(media__type='mp3')
+ books = books.filter(media__type='mp3')
.distinct()
if daisy:
if daisy:
- books = books.filter(media__type='daisy')
+ books = books.filter(media__type='daisy')
.distinct()
if books.exists():
return books
if books.exists():
return books
@@
-224,6
+230,10
@@
class BooksHandler(BookDetailHandler):
return rc.NOT_FOUND
return rc.NOT_FOUND
+class EBooksHandler(AnonymousBooksHandler):
+ fields = ('author', 'href', 'title', 'cover') + tuple(Book.ebook_formats)
+
+
# add categorized tags fields for Book
def _tags_getter(category):
@classmethod
# add categorized tags fields for Book
def _tags_getter(category):
@classmethod