from rest_framework import serializers
from .models import SchemaMeta
from .models import Schema
from .models import Survey


class SchemaSerializer(serializers.ModelSerializer):
    class Meta:
        model = SchemaMeta
        fields = ('eq_id', 'survey', 'file_name', 'created', 'modified', 'title', 'description')


class QuestionnaireSerializer(serializers.Serializer):
        json_data = serializers.JSONField()

        def create(self, validated_data):
            return Schema(validated_data.get('json_data'))

        def update(self, instance, validated_data):
            return Schema(validated_data)


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)
    
    class Meta:
        model = Survey
        fields = ('survey_id', 'title', 'created_at', 'questionnaires')

6cb6d0c883c686a35efe8b8cb2443532c0a8e190
<mask token>


class QuestionnaireSerializer(serializers.Serializer):
    <mask token>

    def create(self, validated_data):
        return Schema(validated_data.get('json_data'))
    <mask token>


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)


    class Meta:
        model = Survey
        fields = 'survey_id', 'title', 'created_at', 'questionnaires'

<mask token>


class QuestionnaireSerializer(serializers.Serializer):
    json_data = serializers.JSONField()

    def create(self, validated_data):
        return Schema(validated_data.get('json_data'))

    def update(self, instance, validated_data):
        return Schema(validated_data)


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)


    class Meta:
        model = Survey
        fields = 'survey_id', 'title', 'created_at', 'questionnaires'

<mask token>


class SchemaSerializer(serializers.ModelSerializer):


    class Meta:
        model = SchemaMeta
        fields = ('eq_id', 'survey', 'file_name', 'created', 'modified',
            'title', 'description')


class QuestionnaireSerializer(serializers.Serializer):
    json_data = serializers.JSONField()

    def create(self, validated_data):
        return Schema(validated_data.get('json_data'))

    def update(self, instance, validated_data):
        return Schema(validated_data)


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)


    class Meta:
        model = Survey
        fields = 'survey_id', 'title', 'created_at', 'questionnaires'

from rest_framework import serializers
from .models import SchemaMeta
from .models import Schema
from .models import Survey


class SchemaSerializer(serializers.ModelSerializer):


    class Meta:
        model = SchemaMeta
        fields = ('eq_id', 'survey', 'file_name', 'created', 'modified',
            'title', 'description')


class QuestionnaireSerializer(serializers.Serializer):
    json_data = serializers.JSONField()

    def create(self, validated_data):
        return Schema(validated_data.get('json_data'))

    def update(self, instance, validated_data):
        return Schema(validated_data)


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)


    class Meta:
        model = Survey
        fields = 'survey_id', 'title', 'created_at', 'questionnaires'

from rest_framework import serializers
from .models import SchemaMeta
from .models import Schema
from .models import Survey


class SchemaSerializer(serializers.ModelSerializer):
    class Meta:
        model = SchemaMeta
        fields = ('eq_id', 'survey', 'file_name', 'created', 'modified', 'title', 'description')


class QuestionnaireSerializer(serializers.Serializer):
        json_data = serializers.JSONField()

        def create(self, validated_data):
            return Schema(validated_data.get('json_data'))

        def update(self, instance, validated_data):
            return Schema(validated_data)


class SurveySerializer(serializers.ModelSerializer):
    questionnaires = SchemaSerializer(many=True, read_only=True)
    
    class Meta:
        model = Survey
        fields = ('survey_id', 'title', 'created_at', 'questionnaires')
