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')
url = AbsoluteURLField()
authors = TagSerializer(many=True)
+ translators = TranslatorSerializer(many=True)
epochs = TagSerializer(many=True)
genres = TagSerializer(many=True)
kinds = TagSerializer(many=True)
model = Book
fields = [
'title', 'url',
- 'epochs', 'genres', 'kinds', 'authors',
+ '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'
def genre_unicode(self):
return self.tag_unicode('genre')
+ def translators(self):
+ translators = self.get_extra_info_json().get('translators')
+ return [
+ '\xa0'.join(reversed(translator.split(', ', 1))) for translator in translators
+ ]
+
def translator(self):
translators = self.get_extra_info_json().get('translators')
if not translators: