from rest_framework import serializers
from .models import Identity
from django.conf import settings
from .models import Frontend

class FrontendSerializer(serializers.ModelSerializer):
    class Meta:
        model = Frontend
        fields = '__all__'  # Include all fields of the Frontend model or specify them individually



class IdentitySerializer(serializers.ModelSerializer):
    service_name = serializers.SerializerMethodField()
    service_root = serializers.SerializerMethodField()
    frontend = FrontendSerializer()

    class Meta:
        model = Identity
        fields = ['name', 'service_type', 'enable_admin', 'description', 'service_name', 'service_root', 'frontend']

    def get_service_name(self, obj):
        return settings.SERVICE_NAME

    def get_service_root(self, obj):
        return settings.SERVICE_ROOT


