Commit 80b8061f authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add VideoFileSerializer

parent fb402a1a
......@@ -5,12 +5,20 @@ from .models import Video
class VideoSerializer(serializers.ModelSerializer):
file = serializers.FileField(read_only=True)
class Meta:
model = Video
fields = ('id', 'name', 'youtube_id', 'file')
fields = ('id', 'name', 'youtube_id', 'file',)
#def get_file(self, obj):
# with fallbacks(False):
# files = VideoFileSerializer(required=False, allow_null=True, read_only=True, **{'context': self.context}).data
# files = [f for f in files if f['file'] != None]
# return files
class VideoFileSerializer(serializers.ModelSerializer):
class Meta:
model = Video
fields = ('id', 'file',)
......@@ -3,7 +3,7 @@ from django.shortcuts import render
from rest_framework import viewsets
from courses.videos.models import Video
from courses.videos.serializers import VideoSerializer
from courses.videos.serializers import VideoFileSerializer
from courses.permissions import (
IsProfessorCoordinatorOrAdminPermissionOrReadOnly,
......@@ -14,5 +14,5 @@ class VideoViewSet(viewsets.ModelViewSet):
model = Video
queryset = Video.objects.all()
serializer_class = VideoSerializer
serializer_class = VideoFileSerializer
permission_classes = (IsProfessorCoordinatorOrAdminPermissionOrReadOnly,)
......@@ -321,4 +321,4 @@ class CoursePictureUploadViewSet(viewsets.ModelViewSet):
serializer.save()
return Response(serializer.data, status=200)
else:
return Response(serializer.errors, status=400)
\ No newline at end of file
return Response(serializer.errors, status=400)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment