From 51369735b0c2f71ee63c1403da3254d5efed2b93 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 27 Nov 2017 16:44:46 +0100 Subject: [PATCH] quotes in API --- src/api/handlers.py | 3 ++- src/catalogue/models/book.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api/handlers.py b/src/api/handlers.py index bc8843b16..6f7179bd5 100644 --- a/src/api/handlers.py +++ b/src/api/handlers.py @@ -280,7 +280,8 @@ class EBooksHandler(AnonymousBooksHandler): class FilterBooksHandler(AnonymousBooksHandler): - fields = book_tag_categories + ['href', 'title', 'url', 'cover', 'cover_thumb', 'slug', 'cover_source_image'] + fields = book_tag_categories + [ + 'href', 'title', 'url', 'cover', 'cover_thumb', 'slug', 'cover_source_image', 'fragment_data'] def read(self, request, title_part=None, author_part=None, is_lektura=None, is_audiobook=None, after=None, before=None, count=None): diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 3715e7b98..00921b899 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -615,6 +615,13 @@ class Book(models.Model): else: return None + def fragment_data(self): + fragment = self.choose_fragment() + if fragment: + return {'title': fragment.book.pretty_title(), 'html': fragment.get_short_text()} + else: + return None + def update_popularity(self): count = self.tags.filter(category='set').values('user').order_by('user').distinct().count() try: -- 2.20.1