o
    /yf                     @   s   d dl mZ ddlT d dlmZmZ G dd dejZG dd dejZG d	d
 d
ejZ	G dd dejZ
G dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZdS )    )serializers   )*)VehicleVehicleTypec                   @      e Zd ZG dd dZdS )LocationSerializerc                   @      e Zd ZeZdZdS )zLocationSerializer.Meta__all__N)__name__
__module____qualname__Locationmodelfields r   r   )/var/www/html/loop/booking/serializers.pyMeta       r   Nr   r   r   r   r   r   r   r   r          r   c                   @   r   )RideSerializerc                   @   r	   )zRideSerializer.Metar
   N)r   r   r   Rider   r   r   r   r   r   r      r   r   Nr   r   r   r   r   r   
   r   r   c                       s*   e Zd ZG dd dZ fddZ  ZS )SharedRideSerializerc                   @   r	   )zSharedRideSerializer.Metar
   N)r   r   r   
SharedRider   r   r   r   r   r   r      r   r   c                    s(   t  |}dd |j D |d< |S )Nc                 S   s0   g | ]}||j |j|j|j|j|j|jd qS ))participantdevice_tokenpickup_locationdropoff_locationpickup_namedropoff_nameseats_required	joined_at)r   r   r   r   r    r!   r"   ).0r   r   r   r   
<listcomp>   s    
z:SharedRideSerializer.to_representation.<locals>.<listcomp>participants)superto_representationr%   all)selfinstanceride_representation	__class__r   r   r'      s
   

z&SharedRideSerializer.to_representation)r   r   r   r   r'   __classcell__r   r   r,   r   r      s    r   c                   @   r   )RoutePointSerializerc                   @      e Zd ZeZg dZdS )zRoutePointSerializer.Metanamelatitude	longitudeNr   r   r   
RoutePointr   r   r   r   r   r   r   %       r   Nr   r   r   r   r   r/   $   r   r/   c                   @   s6   e Zd Ze Ze Ze ZG dd dZ	dd Z
dS )RouteSerializerc                   @   r0   )zRouteSerializer.Meta)idr2   descriptionpickup_pointdropoff_pointintermediate_pointsN)r   r   r   Router   r   r   r   r   r   r   .   r7   r   c                 C   s6   |j djddd}tjj|d}t|ddj}|S )NorderpointT)flat)pk__in)many)	sequencesorder_byvalues_listr6   objectsfilterr/   data)r)   objintermediate_points_qsr=   intermediate_points_serializedr   r   r   get_intermediate_points2   s   z'RouteSerializer.get_intermediate_pointsN)r   r   r   r/   r;   r<   r   SerializerMethodFieldr=   r   rM   r   r   r   r   r8   )   s    r8   c                   @   r   )ScheduledRideMasterSerializerc                   @   r	   )z"ScheduledRideMasterSerializer.Metar
   Nr   r   r   ScheduledRideMasterr   r   r   r   r   r   r   :   r   r   Nr   r   r   r   r   rO   9   r   rO   c                   @   r   )SRMRoutePointSerializerc                   @   r0   )zSRMRoutePointSerializer.Metar1   Nr5   r   r   r   r   r   ?   r7   r   Nr   r   r   r   r   rR   >   r   rR   c                   @   r   )SRMVehicleTypeSerializerc                   @   r0   )zSRMVehicleTypeSerializer.Meta)r9   vehicle_typeseating_capacityN)r   r   r   r   r   r   r   r   r   r   r   D   r7   r   Nr   r   r   r   r   rS   C   r   rS   c                   @   s    e Zd Ze ZG dd dZdS )SRMVehicleSerializerc                   @   r0   )zSRMVehicleSerializer.Meta)r9   plate_numberrT   N)r   r   r   r   r   r   r   r   r   r   r   K   r7   r   N)r   r   r   rS   rT   r   r   r   r   r   rV   H   s    rV   c                   @   s.   e Zd Ze Ze Ze Z	G dd dZ
dS )ScheduledRideMobileSerializerc                   @   r0   )z"ScheduledRideMobileSerializer.Meta)r9   r2   starting_timeending_timeroutevehicledistance_to_startNrP   r   r   r   r   r   V   r7   r   N)r   r   r   r8   r[   rV   r\   r   
FloatFieldr]   r   r   r   r   r   rX   P   s
    rX   N)rest_frameworkr   modelsvehiclehub.modelsr   r   ModelSerializerr   r   r   r/   r8   rO   rR   rS   rV   rX   r   r   r   r   <module>   s    