Merge pull request #1885 from normanjaeckel/MediafileFix
Fixed mediaifle app.
This commit is contained in:
commit
cc657b1fee
@ -37,6 +37,8 @@ class MediafileSerializer(ModelSerializer):
|
|||||||
"""
|
"""
|
||||||
super(MediafileSerializer, self).__init__(*args, **kwargs)
|
super(MediafileSerializer, self).__init__(*args, **kwargs)
|
||||||
self.serializer_field_mapping[dbmodels.FileField] = AngularCompatibleFileField
|
self.serializer_field_mapping[dbmodels.FileField] = AngularCompatibleFileField
|
||||||
|
if self.instance is not None:
|
||||||
|
self.fields['mediafile'].read_only = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Mediafile
|
model = Mediafile
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from ..utils.rest_api import ModelViewSet
|
from ..utils.rest_api import ModelViewSet, ValidationError
|
||||||
from .models import Mediafile
|
from .models import Mediafile
|
||||||
from .serializers import MediafileSerializer
|
from .serializers import MediafileSerializer
|
||||||
|
|
||||||
@ -45,4 +45,6 @@ class MediafileViewSet(ModelViewSet):
|
|||||||
not request.user.has_perm('mediafiles.can_manage') and
|
not request.user.has_perm('mediafiles.can_manage') and
|
||||||
str(self.request.user.pk) != str(uploader_id)):
|
str(self.request.user.pk) != str(uploader_id)):
|
||||||
self.permission_denied(request)
|
self.permission_denied(request)
|
||||||
|
if not self.request.data.get('mediafile'):
|
||||||
|
raise ValidationError({'details': 'You forgot to provide a file.'})
|
||||||
return super().create(request, *args, **kwargs)
|
return super().create(request, *args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user