From 06aa9a0cfb91249b55aafe26967730c3ea29ad96 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 12 Nov 2012 16:52:57 +0100 Subject: [PATCH] Add ebooks listing to api --- apps/api/handlers.py | 4 ++++ apps/api/urls.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/apps/api/handlers.py b/apps/api/handlers.py index e04710f32..be5993cd9 100644 --- a/apps/api/handlers.py +++ b/apps/api/handlers.py @@ -230,6 +230,10 @@ class BooksHandler(BookDetailHandler): 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 diff --git a/apps/api/urls.py b/apps/api/urls.py index e24c3c523..8a1451909 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -15,6 +15,7 @@ tag_changes_resource = Resource(handler=handlers.TagChangesHandler) changes_resource = Resource(handler=handlers.ChangesHandler) book_list_resource = CsrfExemptResource(handler=handlers.BooksHandler, authentication=auth) +ebook_list_resource = Resource(handler=handlers.EBooksHandler) #book_list_resource = Resource(handler=handlers.BooksHandler) book_resource = Resource(handler=handlers.BookDetailHandler) @@ -57,8 +58,12 @@ urlpatterns = patterns( # books by tags url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})books/$', book_list_resource, name='api_book_list'), + url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})ebooks/$', + ebook_list_resource, name='api_ebook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})parent_books/$', book_list_resource, {"top_level": True}, name='api_parent_book_list'), + url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})parent_ebooks/$', + ebook_list_resource, {"top_level": True}, name='api_parent_ebook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})audiobooks/$', book_list_resource, {"audiobooks": True}, name='api_audiobook_list'), url(r'^(?P(?:(?:[a-z0-9-]+/){2}){0,6})daisy/$', -- 2.20.1