From fecaad844b2fe6ffe7600bb7ab6341a02726ff24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sun, 24 Jan 2016 22:58:45 +0100 Subject: [PATCH] Fixed mediaifle app. --- openslides/mediafiles/serializers.py | 2 ++ openslides/mediafiles/views.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openslides/mediafiles/serializers.py b/openslides/mediafiles/serializers.py index 4f4b0e360..b86f6b2f4 100644 --- a/openslides/mediafiles/serializers.py +++ b/openslides/mediafiles/serializers.py @@ -37,6 +37,8 @@ class MediafileSerializer(ModelSerializer): """ super(MediafileSerializer, self).__init__(*args, **kwargs) self.serializer_field_mapping[dbmodels.FileField] = AngularCompatibleFileField + if self.instance is not None: + self.fields['mediafile'].read_only = True class Meta: model = Mediafile diff --git a/openslides/mediafiles/views.py b/openslides/mediafiles/views.py index 08b300422..6c09f0b61 100644 --- a/openslides/mediafiles/views.py +++ b/openslides/mediafiles/views.py @@ -1,4 +1,4 @@ -from ..utils.rest_api import ModelViewSet +from ..utils.rest_api import ModelViewSet, ValidationError from .models import Mediafile from .serializers import MediafileSerializer @@ -45,4 +45,6 @@ class MediafileViewSet(ModelViewSet): not request.user.has_perm('mediafiles.can_manage') and str(self.request.user.pk) != str(uploader_id)): 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)