"""This module contains the v2 api related-serializers for the accounts app"""

from rest_framework import serializers

from mtp.apps.accounts.models import MTPUser


class MTPUserSerializer(serializers.ModelSerializer):
    """Serializer for the ``MTPUser`` model"""

    language = serializers.CharField(source='natural_language')
    profile_picture = serializers.ImageField(source='photo')
    groups = serializers.SlugRelatedField(
        source='mgroups', many=True, read_only=True, slug_field='name'
    )

    class Meta:
        model = MTPUser
        fields = (
            'id', 'username', 'first_name', 'last_name', 'email',
            'language', 'profile_picture', 'groups',
        )
