spradio-server-django/savepointradio/api/serializers/profiles.py

43 lines
1,002 B
Python
Raw Normal View History

2018-04-05 14:59:30 +00:00
from django.contrib.auth import get_user_model
from rest_framework.serializers import ModelSerializer
from profiles.models import RadioProfile, SongRequest
from .radio import BasicSongRetrieveSerializer
2018-04-05 14:59:30 +00:00
User = get_user_model()
class BasicUserSerializer(ModelSerializer):
class Meta:
model = User
fields = ('id', 'name', 'is_staff')
class FullUserSerializer(ModelSerializer):
class Meta:
model = User
fields = ('id', 'email', 'name', 'is_staff', 'is_active', 'last_login')
class BasicProfileSerializer(ModelSerializer):
user = BasicUserSerializer()
class Meta:
model = RadioProfile
fields = ('id', 'user')
class FullProfileSerializer(BasicProfileSerializer):
user = FullUserSerializer()
class HistorySerializer(ModelSerializer):
profile = BasicProfileSerializer()
song = BasicSongRetrieveSerializer()
class Meta:
model = SongRequest
fields = ('created_date', 'played_at', 'profile', 'song')