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    