from rest_framework import serializers
from authentication.models import UserMessage
from ..serializer.serializer import (
    GroupSerializer,
    SystemUserProfileSerializer
)


# سریالایزر مربوط به سیستم پیام کاربر
class UserMessageSerializer(serializers.ModelSerializer):
    users = SystemUserProfileSerializer(required=False, many=True)
    roles = GroupSerializer(required=False, many=True)
    sender = SystemUserProfileSerializer(required=False)

    class Meta:
        model = UserMessage
        exclude = (
            'id',
            'create_date',
            'modify_date',
            'trash',
            'created_by',
            'modified_by',
        )
        extra_kwargs = {
            'link_text': {'required': False},
            'link': {'required': False}
        }
