from rest_framework import serializers

from base.serializers import DynamicFieldsSerializer


class AdminLoginSerializer(DynamicFieldsSerializer):
    """
    This is the AdminLoginSerializer class responsible for serializing user data during login.

    It is used for authenticating and generating authentication tokens for administrators.

    Fields:
        email (str): The email address of the administrator.
        password (str): The password provided during login.

    Meta:
        model (User): The model used for serialization.
        fields (tuple): Specifies the fields included in the serialization process.
        read_only_fields (tuple): Fields that are marked as read-only.
    """

    password = serializers.CharField(
        required=True, allow_blank=False, allow_null=False, write_only=True
    )
    email = serializers.EmailField(
        required=True, allow_blank=False, allow_null=False, write_only=False
    )


class AdminChangePasswordSerializer(DynamicFieldsSerializer):
    """
    This is the AdminChangePasswordSerializer class responsible for serializing data during the password change process.

    It is used for changing the password of administrators by providing the old and new passwords.

    Fields:
        email (str): The email address of the administrator.
        old_password (str): The current password of the administrator.
        new_password (str): The new password to set for the administrator.
    """

    email = serializers.EmailField(
        required=True, allow_blank=False, allow_null=False, write_only=True
    )
    old_password = serializers.CharField(
        required=True, allow_blank=False, allow_null=False, write_only=True
    )
    new_password = serializers.CharField(
        required=True, allow_blank=False, allow_null=False, write_only=True
    )
