from rest_framework import serializers

from .models import Post


class PostSerializer(serializers.HyperlinkedModelSerializer):
    agenda_html = serializers.CharField(required=False)
    protocol_html = serializers.CharField(required=False)
    tag_string = serializers.CharField(required=False, read_only=True)
    imageurl = serializers.CharField(required=False, read_only=True)

    class Meta:
        model = Post
        fields = [
            "slug",
            "title",
            "subtitle",
            "body",
            "url",
            "post_type",
            "public_date",
            "legacy_id",
            "image",
            "event_start",
            "event_end",
            "agenda_html",
            "protocol_html",
            "has_agenda",
            "has_protocol",
            "tag_string",
            "imageurl"
            # 'author',
        ]

        extra_kwargs = {
            "agenda_html": {"required": False},
            "protocol_html": {"required": False},
        }
