X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/528a34731579d8b81df43879f2b63c2754005a86..131ae407ca583a8a8086cf94c222c85fa3f5be63:/src/catalogue/api/serializers.py?ds=inline diff --git a/src/catalogue/api/serializers.py b/src/catalogue/api/serializers.py index 02a98a154..ee3c5067f 100644 --- a/src/catalogue/api/serializers.py +++ b/src/catalogue/api/serializers.py @@ -1,5 +1,5 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from rest_framework import serializers from api.fields import AbsoluteURLField, LegacyMixin, ThumbnailField @@ -24,13 +24,50 @@ class TagDetailSerializer(serializers.ModelSerializer): class Meta: model = Tag - fields = ['name', 'url', 'sort_key', 'description'] + fields = [ + 'name', 'url', 'sort_key', + 'description', + 'description_pl', + 'plural', 'genre_epoch_specific', + 'adjective_feminine_singular', 'adjective_nonmasculine_plural', + 'genitive', 'collective_noun', + ] + write_only_fields = [ + 'description_pl', + 'plural', 'genre_epoch_specific', + 'adjective_feminine_singular', 'adjective_nonmasculine_plural', + 'genitive', 'collective_noun', + ] class TranslatorSerializer(serializers.Serializer): name = serializers.CharField(source='*') +class BookSerializer2(serializers.ModelSerializer): + url = AbsoluteURLField() + href = AbsoluteURLField(view_name='catalogue_api_book', view_args=['slug']) + xml = EmbargoURLField(source='xml_url') + html = EmbargoURLField(source='html_url') + txt = EmbargoURLField(source='txt_url') + fb2 = EmbargoURLField(source='fb2_url') + epub = EmbargoURLField(source='epub_url') + mobi = EmbargoURLField(source='mobi_url') + pdf = EmbargoURLField(source='pdf_url') + + class Meta: + model = Book + fields = [ + 'full_sort_key', 'title', + 'href', 'url', 'language', + #'epochs', 'genres', 'kinds', 'authors', 'translators', + #'children', + 'parent', 'preview', + 'epub', 'mobi', 'pdf', 'html', 'txt', 'fb2', 'xml', + 'cover_thumb', 'cover', + 'isbn_pdf', 'isbn_epub', 'isbn_mobi', + ] + class BookSerializer(LegacyMixin, serializers.ModelSerializer): author = serializers.CharField(source='author_unicode') kind = serializers.CharField(source='kind_unicode')