from rest_framework import serializers
from datetime import datetime, timedelta
from rates.models import RateLists, Daytimes
from .models import DriverVehicles

class DriverSerializer(serializers.Serializer):
    name = serializers.CharField(source="user.name")
    mobile = serializers.CharField(source="user.mobile")
    email = serializers.CharField(source="user.email")
    profile_pic = serializers.ImageField(source="user.profile_pic")
    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()


    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