+class BookDetails(object):
+ """Custom fields used for representing Books."""
+
+ @classmethod
+ def href(cls, book):
+ """ Returns an URI for a Book in the API. """
+ return API_BASE + reverse("api_book", args=[book.slug])
+
+ @classmethod
+ def url(cls, book):
+ """ Returns Book's URL on the site. """
+
+ return WL_BASE + book.get_absolute_url()
+
+ @classmethod
+ def children(cls, book):
+ """ Returns all children for a book. """
+
+ return book.children.all()
+
+ @classmethod
+ def media(cls, book):
+ """ Returns all media for a book. """
+ return book.media.all()
+
+ @classmethod
+ 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):
+ """ Main handler for Book objects.
+
+ Responsible for single Book details.