from datetime import datetime, timedelta
import json
+from urlparse import urljoin
from django.conf import settings
from django.contrib.sites.models import Site
@classmethod
def author(cls, book):
- return ", ".join(t.name for t in book.tags.filter(category='author'))
+ return ",".join(t[0] for t in book.related_info()['tags']['author'])
@classmethod
def href(cls, book):
@classmethod
def children(cls, book):
- """ Returns all media for a 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 ''
+
class BookDetailHandler(BaseHandler, BookDetails):
"""
allowed_methods = ('GET',)
model = Book
- fields = ['author', 'href', 'title', 'url']
+ fields = ['author', 'href', 'title', 'url', 'cover']
@piwik_track
def read(self, request, tags, top_level=False):
class BooksHandler(BookDetailHandler):
+ allowed_methods = ('GET', 'POST')
model = Book
fields = ['author', 'href', 'title', 'url']
anonymous = AnonymousBooksHandler