2015-01-24 16:35:50 +01:00
|
|
|
from openslides.utils.rest_api import serializers
|
|
|
|
|
|
|
|
from .models import Mediafile
|
|
|
|
|
|
|
|
|
2015-02-04 00:08:38 +01:00
|
|
|
class MediafileSerializer(serializers.ModelSerializer):
|
2015-01-24 16:35:50 +01:00
|
|
|
"""
|
|
|
|
Serializer for mediafile.models.Mediafile objects.
|
|
|
|
"""
|
|
|
|
filesize = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Mediafile
|
2015-02-04 00:08:38 +01:00
|
|
|
fields = (
|
|
|
|
'id',
|
|
|
|
'title',
|
|
|
|
'mediafile',
|
|
|
|
'uploader',
|
|
|
|
'filesize',
|
|
|
|
'filetype',
|
|
|
|
'timestamp',
|
|
|
|
'is_presentable',)
|
2015-01-24 16:35:50 +01:00
|
|
|
|
|
|
|
def get_filesize(self, mediafile):
|
|
|
|
return mediafile.get_filesize()
|