from re import template
from django.db.models.base import Model
from rest_framework import serializers
from .models import *
from apps.system.serializers import FileSerializer
from rest_framework.exceptions import ParseError, APIException

class RegulatorySerializer(serializers.ModelSerializer):

    file_ = FileSerializer(source='file', read_only=True)
    class Meta:
        model = Regulatory
        fields = '__all__'
    @staticmethod
    def setup_eager_loading(queryset):
        queryset = queryset.select_related('file')
        return queryset
class ProfessionalSerializer(serializers.ModelSerializer):

    file_ = FileSerializer(source='file', read_only=True)
    class Meta:
        model = Professional
        fields = '__all__'
    @staticmethod
    def setup_eager_loading(queryset):
        queryset = queryset.select_related('file')
        return queryset
class PolicySerializer(serializers.ModelSerializer):

    file_ = FileSerializer(source='file', read_only=True)
    class Meta:
        model = Policy
        fields = '__all__'
    @staticmethod
    def setup_eager_loading(queryset):
        queryset = queryset.select_related('file')
        return queryset
class ValidationSerializer(serializers.ModelSerializer):

    file_ = FileSerializer(source='file', read_only=True)
    class Meta:
        model = Validation
        fields = '__all__'
    @staticmethod
    def setup_eager_loading(queryset):
        queryset = queryset.select_related('file')
        return queryset