From 033aad30ca189472af0e04309cab1bc5964c9119 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 3 Apr 2020 11:46:10 +0200 Subject: [PATCH] Add ISBNs in API. --- src/catalogue/api/serializers.py | 3 ++- src/catalogue/models/book.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/catalogue/api/serializers.py b/src/catalogue/api/serializers.py index d52959b92..99a634675 100644 --- a/src/catalogue/api/serializers.py +++ b/src/catalogue/api/serializers.py @@ -110,7 +110,8 @@ class BookDetailSerializer(LegacyMixin, serializers.ModelSerializer): 'epochs', 'genres', 'kinds', 'authors', 'translators', 'fragment_data', 'children', 'parent', 'preview', 'epub', 'mobi', 'pdf', 'html', 'txt', 'fb2', 'xml', 'media', 'audio_length', - 'cover_color', 'simple_cover', 'cover_thumb', 'cover', 'simple_thumb' + 'cover_color', 'simple_cover', 'cover_thumb', 'cover', 'simple_thumb', + 'isbn_pdf', 'isbn_epub', 'isbn_mobi', ] legacy_non_null_fields = ['html', 'txt', 'fb2', 'epub', 'mobi', 'pdf', 'cover', 'simple_cover', 'cover_thumb', 'simple_thumb'] diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 60ef5d53c..9535e9024 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -198,6 +198,19 @@ class Book(models.Model): def cover_source(self): return self.get_extra_info_json().get('cover_source', self.parent.cover_source() if self.parent else '') + @property + def isbn_pdf(self): + return self.get_extra_info_json().get('isbn_pdf') + + @property + def isbn_epub(self): + return self.get_extra_info_json().get('isbn_epub') + + @property + def isbn_mobi(self): + return self.get_extra_info_json().get('isbn_mobi') + + def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify -- 2.20.1