"""Address serializers"""

# DRF
from rest_framework import serializers

# Models
from {{project_slug}}.locations.models import Address, State, Municipality


class AddressModelSerializer(serializers.ModelSerializer):
    """Address serializer"""

    class Meta:
        model = Address
        fields = ["address", "state", "municipality"]


class ParkingLotAddressModelSerializer(AddressModelSerializer):
    """Parking Lot address serializer"""

    class Meta(AddressModelSerializer.Meta):
        fields = AddressModelSerializer.Meta.fields + ["longitude", "latitude"]


class AddressUpdateModelSerializer(AddressModelSerializer):
    """Address serializer"""

    state = serializers.PrimaryKeyRelatedField(queryset=State.objects.all())
    municipality = serializers.PrimaryKeyRelatedField(
        queryset=Municipality.objects.all()
    )


class ParkingLotAddressUpdateModelSerializer(AddressUpdateModelSerializer):
    """Parking Lot address update serializer"""

    longitude = serializers.CharField(max_length=20, required=True)
    latitude = serializers.CharField(max_length=20, required=True)

    class Meta(AddressUpdateModelSerializer.Meta):
        fields = AddressUpdateModelSerializer.Meta.fields + ["longitude", "latitude"]
