"""This module holds the serializers of the ``documents`` app."""
from mtp.apps.documents.models import Note
from rest_framework import serializers

from .models import (
    Document,
)


class CompatibilityReadDocumentSerializer(serializers.Serializer):
    """Serializer for the ``mtp.apps.document.models.Document`` model."""

    def to_representation(self, instance):
        return {}


class NoteSerializer(serializers.ModelSerializer):
    id_doc = serializers.ReadOnlyField(source='document.id')
    type = serializers.ReadOnlyField(source='note_type')

    x = serializers.FloatField(default=0, source='coord_x')
    y = serializers.FloatField(default=0, source='coord_y')

    w = serializers.FloatField(default=0, source='width')
    h = serializers.FloatField(default=0, source='height')

    class Meta:
        model = Note
        fields = (
            'id', 'x', 'y', 'h', 'w',
            'id_doc', 'page', 'text', 'type'
        )
