X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c15b511c1e9ebb06050f40e98ec554ba6c26cb1b..30ceb98e6272767f8f271ecb0de30858e1c1a88e:/src/catalogue/api/serializers.py diff --git a/src/catalogue/api/serializers.py b/src/catalogue/api/serializers.py index 79bb58b6c..06832e794 100644 --- a/src/catalogue/api/serializers.py +++ b/src/catalogue/api/serializers.py @@ -27,6 +27,10 @@ class TagDetailSerializer(serializers.ModelSerializer): fields = ['name', 'url', 'sort_key', 'description'] +class TranslatorSerializer(serializers.Serializer): + name = serializers.CharField(source='*') + + class BookSerializer(LegacyMixin, serializers.ModelSerializer): author = serializers.CharField(source='author_unicode') kind = serializers.CharField(source='kind_unicode') @@ -79,6 +83,7 @@ class BookDetailSerializer(LegacyMixin, serializers.ModelSerializer): url = AbsoluteURLField() authors = TagSerializer(many=True) + translators = TranslatorSerializer(many=True) epochs = TagSerializer(many=True) genres = TagSerializer(many=True) kinds = TagSerializer(many=True) @@ -101,11 +106,12 @@ class BookDetailSerializer(LegacyMixin, serializers.ModelSerializer): class Meta: model = Book fields = [ - 'title', 'url', - 'epochs', 'genres', 'kinds', 'authors', + 'title', 'url', 'language', + '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'] @@ -141,12 +147,13 @@ class CollectionListSerializer(serializers.ModelSerializer): class CollectionSerializer(serializers.ModelSerializer): - books = BookSerializer(many=True, source='get_books') + books = BookSerializer(many=True, source='get_books', read_only=True) + book_slugs = serializers.CharField(write_only=True) url = AbsoluteURLField() class Meta: model = Collection - fields = ['url', 'books', 'description', 'title'] + fields = ['url', 'books', 'description', 'title', 'book_slugs'] class FragmentSerializer(serializers.ModelSerializer):