update
This commit is contained in:
47
gnx-react/backend/policies/serializers.py
Normal file
47
gnx-react/backend/policies/serializers.py
Normal file
@@ -0,0 +1,47 @@
|
||||
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'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user