"""This module contains the serializers for the v2 api of the ``metaplans`` app"""

from rest_framework import serializers

from mtp.apps.accounts.apiv2.serializers import MTPUserSerializer
from mtp.apps.metaplans.models import Metaplan, MetaplanProposition


class MetaplanPropositionSerializer(serializers.ModelSerializer):
    """Serializer for the ``MetaplanProposition`` model"""

    user = MTPUserSerializer()

    class Meta:
        model = MetaplanProposition
        fields = (
            'user',
            'group',
            'text'
        )


class MetaplanSerializer(serializers.ModelSerializer):
    """Serializer for the ``Metaplan`` model"""

    propositions = MetaplanPropositionSerializer(many=True)

    class Meta:
        model = Metaplan
        fields = (
            'id',
            'name',
            'propositions',
        )
