SongCreateSerializer no longer needed.

This commit is contained in:
Josh Washburne 2018-04-04 11:04:50 -04:00
parent 6dd4fa72ec
commit 253ee3ddd2
2 changed files with 1 additions and 14 deletions

View file

@ -34,17 +34,6 @@ class SongSerializer(serializers.ModelSerializer):
'num_played', 'last_played', 'length', 'song_type', 'title')
class SongCreateSerializer(SongSerializer):
def create(self, validated_data):
artists_data = validated_data.pop('artists')
song = Song.objects.create(**validated_data)
for artist_data in artists_data:
song.artists.add(artist_data)
song.save()
return song
class SongRetrieveSerializer(SongSerializer):
artists = ArtistFullnameSerializer(many=True)

View file

@ -8,7 +8,7 @@ from ..permissions import IsAdminOrReadOnly
from ..serializers.radio import (AlbumSerializer, ArtistSerializer,
GameSerializer, SongSerializer,
SongArtistsListSerializer,
SongCreateSerializer, SongRetrieveSerializer)
SongRetrieveSerializer)
class AlbumViewSet(viewsets.ModelViewSet):
@ -40,8 +40,6 @@ class SongViewSet(viewsets.ModelViewSet):
(Thanks to https://stackoverflow.com/questions/22616973/)
'''
if self.action == 'create':
return SongCreateSerializer
if self.action in ['list', 'retrieve']:
return SongRetrieveSerializer
return SongSerializer