from rest_framework import serializers
from .models import Policy, PolicySection


class PolicySectionSerializer(serializers.ModelSerializer):
    """Serializer for policy sections"""
    
    class Meta:
        model = PolicySection
        fields = ['id', 'heading', 'content', 'order']


class PolicySerializer(serializers.ModelSerializer):
    """Serializer for policies with their sections"""
    
    sections = PolicySectionSerializer(many=True, read_only=True)
    
    class Meta:
        model = Policy
        fields = [
            'id',
            'type',
            'title',
            'slug',
            'description',
            'last_updated',
            'version',
            'effective_date',
            'sections'
        ]


class PolicyListSerializer(serializers.ModelSerializer):
    """Simplified serializer for policy listing"""
    
    class Meta:
        model = Policy
        fields = [
            'id',
            'type',
            'title',
            'slug',
            'description',
            'last_updated',
            'version'
        ]

