2015-02-12 18:48:14 +01:00
|
|
|
from openslides.utils.rest_api import ModelSerializer, SerializerMethodField
|
2015-01-24 16:35:50 +01:00
|
|
|
|
|
|
|
from .models import Mediafile
|
|
|
|
|
|
|
|
|
2015-02-12 18:48:14 +01:00
|
|
|
class MediafileSerializer(ModelSerializer):
|
2015-01-24 16:35:50 +01:00
|
|
|
"""
|
|
|
|
Serializer for mediafile.models.Mediafile objects.
|
|
|
|
"""
|
2015-02-12 18:48:14 +01:00
|
|
|
filesize = SerializerMethodField()
|
2015-01-24 16:35:50 +01:00
|
|
|
|
|
|
|
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()
|