コード例 #1
0
ファイル: serializers.py プロジェクト: rdm-dev12/RDM-osf.io
    def to_representation(self, data, envelope='data'):

        if isinstance(data, AbstractNode):
            if data.is_registration:
                serializer = RegistrationSerializer(data, context=self.context)
                return RegistrationSerializer.to_representation(
                    serializer, data)
            serializer = NodeSerializer(data, context=self.context)
            return NodeSerializer.to_representation(serializer, data)

        if isinstance(data, OSFUser):
            serializer = UserSerializer(data, context=self.context)
            return UserSerializer.to_representation(serializer, data)

        if isinstance(data, BaseFileNode):
            serializer = FileSerializer(data, context=self.context)
            return FileSerializer.to_representation(serializer, data)

        if isinstance(data, Institution):
            serializer = InstitutionSerializer(data, context=self.context)
            return InstitutionSerializer.to_representation(serializer, data)

        if isinstance(data, CollectionSubmission):
            serializer = CollectionSubmissionSerializer(data,
                                                        context=self.context)
            return CollectionSubmissionSerializer.to_representation(
                serializer, data)

        return None
コード例 #2
0
ファイル: serializers.py プロジェクト: erinspace/osf.io
    def to_representation(self, data, envelope='data'):

        if isinstance(data, AbstractNode):
            if data.is_registration:
                serializer = RegistrationSerializer(data, context=self.context)
                return RegistrationSerializer.to_representation(serializer, data)
            serializer = NodeSerializer(data, context=self.context)
            return NodeSerializer.to_representation(serializer, data)

        if isinstance(data, OSFUser):
            serializer = UserSerializer(data, context=self.context)
            return UserSerializer.to_representation(serializer, data)

        if isinstance(data, BaseFileNode):
            serializer = FileSerializer(data, context=self.context)
            return FileSerializer.to_representation(serializer, data)

        if isinstance(data, Institution):
            serializer = InstitutionSerializer(data, context=self.context)
            return InstitutionSerializer.to_representation(serializer, data)

        if isinstance(data, CollectedGuidMetadata):
            serializer = CollectedMetaSerializer(data, context=self.context)
            return CollectedMetaSerializer.to_representation(serializer, data)

        return None
コード例 #3
0
    def to_representation(self, data, envelope="data"):

        if isinstance(data, Node):
            if data.is_registration:
                serializer = RegistrationSerializer(data, context=self.context)
                return RegistrationSerializer.to_representation(serializer, data)
            serializer = NodeSerializer(data, context=self.context)
            return NodeSerializer.to_representation(serializer, data)

        if isinstance(data, User):
            serializer = UserSerializer(data, context=self.context)
            return UserSerializer.to_representation(serializer, data)

        if isinstance(data, FileNode):
            serializer = FileSerializer(data, context=self.context)
            return FileSerializer.to_representation(serializer, data)

        return None
コード例 #4
0
ファイル: serializers.py プロジェクト: BRosenblatt/osf.io
    def to_representation(self, data, envelope='data'):

        if isinstance(data, AbstractNode):
            if data.is_registration:
                serializer = RegistrationSerializer(data, context=self.context)
                return RegistrationSerializer.to_representation(
                    serializer, data)
            serializer = NodeSerializer(data, context=self.context)
            return NodeSerializer.to_representation(serializer, data)

        if isinstance(data, User):
            serializer = UserSerializer(data, context=self.context)
            return UserSerializer.to_representation(serializer, data)

        if isinstance(data, FileNode):
            serializer = FileSerializer(data, context=self.context)
            return FileSerializer.to_representation(serializer, data)

        return None