from rest_framework import serializers

from driver_partners.models import DriverVehicles



class DriverPartnerSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    name = serializers.CharField(source="user.name")
    mobile = serializers.CharField(source="user.mobile")
    email = serializers.CharField(source="user.email")
    status = serializers.IntegerField(source="user.is_active")
    gender = serializers.IntegerField()
    licensce_no = serializers.CharField()
    date_of_birth = serializers.CharField()
    experience = serializers.FloatField()
    location =serializers.CharField()
    house_number = serializers.CharField()
    pincode = serializers.CharField()
    uniform_type = serializers.IntegerField()
    station_type = serializers.IntegerField()
    trip_type = serializers.IntegerField()
    transmission_type = serializers.IntegerField()
    vehicle_models = serializers.SerializerMethodField()
    created_at = serializers.DateTimeField()
    

    def get_vehicle_models(self, obj):
        vehicle_models = list(DriverVehicles.objects.filter(driver_id = obj.user.id).values_list('vehicle_model', flat=True))
        return vehicle_models



class DriverPartnerListSerializer(serializers.Serializer):
    value = serializers.IntegerField(source="user.id")
    label = serializers.CharField(source="user.name")