1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
4 from django.contrib.auth.models import User
5 from rest_framework import serializers
6 from .fields import UserPremiumField
7 from .models import BookUserData
10 class PlainSerializer(serializers.ModelSerializer):
11 def to_representation(self, value):
12 value = super(PlainSerializer, self).to_representation(value)
13 return value.values()[0]
16 class UserSerializer(serializers.ModelSerializer):
17 premium = UserPremiumField()
21 fields = ['username', 'premium']
24 class BookUserDataSerializer(serializers.ModelSerializer):
30 class LoginSerializer(serializers.Serializer):
31 username = serializers.CharField()
32 password = serializers.CharField(style={'input_type': 'password'})