from rest_framework import serializers

from account.models import User
from account.serializers import BackUserSerializer
from main import models


class PanelSerializer(serializers.ModelSerializer):
    """Serializer for Custom panel."""
    user_id = serializers.PrimaryKeyRelatedField(
        queryset=User.objects.all(),
        source='user',
        write_only=True
    )
    user = BackUserSerializer(read_only=True)

    class Meta:
        model = models.Panel
        fields = [
            'id',
            'name',
            'display',
            'description',
            'query',
            'created',
            'modified',
            'user',
            'user_id'
        ]
