Initial commit that merge both the front end and the API in the same repository
This commit is contained in:
commit
76f98b74dd
285 changed files with 51318 additions and 0 deletions
20
api/funkwhale_api/history/serializers.py
Normal file
20
api/funkwhale_api/history/serializers.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from funkwhale_api.music.serializers import TrackSerializerNested
|
||||
from . import models
|
||||
|
||||
|
||||
class ListeningSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = models.Listening
|
||||
fields = ('id', 'user', 'session_key', 'track', 'end_date')
|
||||
|
||||
|
||||
def create(self, validated_data):
|
||||
if self.context.get('user'):
|
||||
validated_data['user'] = self.context.get('user')
|
||||
else:
|
||||
validated_data['session_key'] = self.context['session_key']
|
||||
|
||||
return super().create(validated_data)
|
||||
Loading…
Add table
Add a link
Reference in a new issue