You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
738 B
32 lines
738 B
from rest_framework import serializers
|
|
|
|
from storage.models import File, Comment
|
|
|
|
|
|
class FileSerializer(serializers.ModelSerializer):
|
|
upload = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = File
|
|
fields = ('original', 'name', 'upload')
|
|
|
|
@staticmethod
|
|
def get_upload(self):
|
|
return 'ok'
|
|
|
|
|
|
class CommentSerializer(serializers.ModelSerializer):
|
|
files = serializers.SerializerMethodField()
|
|
upload = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = Comment
|
|
exclude = ('id', 'token',)
|
|
|
|
@staticmethod
|
|
def get_files(self):
|
|
return [FileSerializer(i).data for i in self.files.all()]
|
|
|
|
@staticmethod
|
|
def get_upload(self):
|
|
return 'ok'
|
|
|