from rest_framework import serializers
from .models import Poster
from django.conf import settings

class PosterSerializer(serializers.ModelSerializer):
    location_text = serializers.CharField(source='get_location_display', read_only=True)
    enable_text = serializers.SerializerMethodField()
    create_user_name = serializers.CharField(source='create_user.employee.name', read_only=True)

    def get_enable_text(self,obj):
        if obj.enable:
            return '是'
        return '否'

    class Meta:
        model = Poster
        fields = '__all__'
