o
    pŽfs   ã                   @   s
  d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	 d dl
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G dd„ dejƒZdS )é    )Úmodels)Ú
CustomUserÚDevice)ÚVehicleTypeÚVehicleNc                   @   s0   e Zd Zejdd�Ze ¡ Ze ¡ Zdd„ Z	dS )ÚLocationéd   ©Ú
max_lengthc                 C   ó   | j S ©N©Úname©Úself© r   ú$/var/www/html/loop/booking/models.pyÚ__str__   ó   zLocation.__str__N)
Ú__name__Ú
__module__Ú__qualname__r   Ú	CharFieldr   Ú
FloatFieldÚlatitudeÚ	longituder   r   r   r   r   r      s
    r   c                       s<  e Zd ZdZejeejdd�Zejeejddd�Z	eje
ejddd�Zejeejddd�Zejeejddd�Zejdd	�Zejdd	�Ze ¡ Zejdd
�Zejdd
�Zejdedd�Zejdd�Zejdd�Zejddd�Zejdddd�Zejdddd�Zej ddddd�Z!ej ddddd�Z"‡ fdd„Z#dd„ Z$‡  Z%S )ÚRide©)ÚpendingÚPending)Ú
processingÚ
Processing)ÚacceptedÚAccepted)ÚstartedÚStarted)ÚrejectedÚRejected)Ú	completedÚ	Completed)Ú	cancelledÚ	CancelledÚrides©Ú	on_deleteÚrelated_nameÚdriver_ridesT)r.   r/   ÚnullÚ
user_rides©r.   r1   r/   ©Ú	geography)r1   é
   r   ©r
   ÚchoicesÚdefault©Úauto_now_add©Úauto_nowé   )r
   Úblankéÿ   ©r
   r1   r?   é   )Ú
max_digitsÚdecimal_placesr1   r?   c                    s:   | j sd dd„ tdƒD ƒ¡| _ tt| ƒj|i |¤Ž d S )NÚ c                 S   s   g | ]
}t t d d¡ƒ‘qS )r   é	   )ÚstrÚrandomÚrandint)Ú.0Ú_r   r   r   Ú
<listcomp>0   s    zRide.save.<locals>.<listcomp>r>   )ÚotpÚjoinÚrangeÚsuperr   Úsave)r   ÚargsÚkwargs©Ú	__class__r   r   rQ   .   s   z	Ride.savec                 C   ó   | j j› d| j› �S ©Nú - )ÚuserÚmobile_numberÚstatusr   r   r   r   r   3   ó   zRide.__str__)&r   r   r   ÚSTATUS_CHOICESr   Ú
ForeignKeyr   ÚCASCADErY   Údriverr   ÚSET_NULLÚuser_devicer   Úvehicle_typer   ÚvehicleÚ	geomodelsÚ
PointFieldÚpickup_locationÚdropoff_locationÚDateTimeFieldÚ	ride_timeÚ
start_timeÚend_timer   r[   Ú
created_atÚ
updated_atrM   Úpickup_nameÚdropoff_nameÚDecimalFieldÚdistanceÚestimated_farerQ   r   Ú__classcell__r   r   rT   r   r      s,    r   c                   @   s^   e Zd Zejeejdd�Zejeejdd�Z	ej
dd�Zejddd�Zejdd�Zdd	„ Zd
S )ÚDriverResponseLogÚdriver_responsesr-   é2   r	   T)r1   r?   r:   c                 C   rV   rW   )r`   rZ   Úresponser   r   r   r   r   =   r\   zDriverResponseLog.__str__N)r   r   r   r   r^   r   r_   Úrider   r`   r   rx   Ú	TextFieldÚreasonri   Ú	timestampr   r   r   r   r   ru   6   s    ru   c                   @   sØ   e Zd ZdZejeejddd�Zeje	ej
dd�Zejdd�Zejdd�Ze ¡ Ze ¡ Zejdd	�Zejd
edd�Zejdd�Zejdd�Zejdddd�Zejdddd�Zejdd	�Zejeejdd�Zdd„ ZdS )Ú
SharedRider   TÚshared_ridesr3   Úinitiated_shared_ridesr-   r4   r   ©r9   é   r   r7   r:   r<   r@   rA   ©r.   r1   c                 C   rV   rW   )Úprimary_userrZ   r[   r   r   r   r   r   Z   r\   zSharedRide.__str__N)r   r   r   r]   r   r^   r   ra   rc   r   r_   rƒ   re   rf   Úprimary_pickup_locationÚprimary_dropoff_locationri   rj   ÚPositiveIntegerFieldÚseats_totalÚseats_occupiedr   r[   rm   rn   ro   rp   Úseats_requiredr   rb   r   r   r   r   r   r}   @   s"    
r}   c                   @   sš   e Zd Zejeejdd�Zejeejdd�Z	e
jdd�Ze
jdd�Zejdddd�Zejdddd�Zejdd	�Zejeejdd
�Zejdd�Zdd„ ZdS )ÚSharedRideParticipantÚparticipantsr-   Úshared_ride_participationTr4   r@   rA   r   r€   r‚   r:   c                 C   s
   | j j› S r   )Úparticipant_userrZ   r   r   r   r   r   h   s   
zSharedRideParticipant.__str__N)r   r   r   r   r^   r}   r_   Úshared_rider   r�   re   rf   rg   rh   r   ro   rp   r†   r‰   r   ra   Údevice_tokenri   Ú	joined_atr   r   r   r   r   rŠ   ]   s    rŠ   c                   @   s<   e Zd Zejdd�Ze ¡ Ze ¡ Ze	j
dd� dd„ ZdS )Ú
RoutePointéÈ   r	   Tr4   c                 C   r   r   r   r   r   r   r   r   q   r   zRoutePoint.__str__N)r   r   r   r   r   r   r   r   r   re   rf   r   r   r   r   r   r‘   k   s    r‘   c                   @   sj   e Zd Zejdd�Ze ¡ Zeje	ej
dd�Zeje	ej
dd�Zeje	dd�Zdd	„ Zd
d„ Zdd„ ZdS )ÚRouter   r	   Úroutes_as_pickupr-   Úroutes_as_dropoffÚroutes_as_intermediate)r/   c                 C   r   r   r   r   r   r   r   r   {   r   zRoute.__str__c                 C   s"   || j  ¡ vr| j  |¡ d S d S r   )Úintermediate_pointsÚallÚadd©r   Úpointr   r   r   Úadd_intermediate_point~   ó   ÿzRoute.add_intermediate_pointc                 C   s"   || j  ¡ v r| j  |¡ d S d S r   )r—   r˜   Úremoverš   r   r   r   Úremove_intermediate_point‚   r�   zRoute.remove_intermediate_pointN)r   r   r   r   r   r   rz   Údescriptionr^   r‘   r_   Úpickup_pointÚdropoff_pointÚManyToManyFieldr—   r   rœ   rŸ   r   r   r   r   r“   t   s    r“   c                   @   s@   e Zd Zejeejdd�Zejeejdd�Z	e 
¡ Zdd„ ZdS )ÚSequenceÚ	sequencesr-   c                 C   rV   rW   )r›   r   Úorderr   r   r   r   r   ‹   r\   zSequence.__str__N)r   r   r   r   r^   r“   r_   Úrouter‘   r›   r†   r¦   r   r   r   r   r   r¤   †   s
    r¤   c                   @   st   e Zd Zejdd�Ze ¡ Ze ¡ Zej	e
ejdd�Zej	eejdd�Zejdd�Zejdddgd	d
�Zdd„ ZdS )ÚScheduledRideMasterr   r	   Tr‚   r:   r�   )ÚactiveÚActive)ÚinactiveÚInactiver©   r7   c                 C   s   | j › d| j› d| j› �S )NrX   z to )r   Ústarting_timeÚending_timer   r   r   r   r   —   s   zScheduledRideMaster.__str__N)r   r   r   r   r   r   Ú	TimeFieldr­   r®   r^   r“   ra   r§   r   r_   rd   ri   Úassigned_atr[   r   r   r   r   r   r¨   Ž   s    r¨   c                   @   s`   e Zd ZdZejeejd�Zej	dedd�Z
e ¡ Ze ¡ Zejdd�Zejdd	�Zd
d„ ZdS )ÚScheduledRideDayr   ©r.   r�   r   r7   r   r€   Tr:   c                 C   rV   rW   )Úscheduled_rider   Údater   r   r   r   r   «   r\   zScheduledRideDay.__str__N)r   r   r   r]   r   r^   r¨   r_   r³   r   r[   Ú	DateFieldr´   r†   Útotal_seatsÚbooked_seatsri   rm   r   r   r   r   r   r±   š   s    	r±   c                   @   sd   e Zd Zejeejd�Zejeejd�Z	e
jdd�Ze
jdd�Zejdd�Zejdd�Zdd„ Zd	S )
ÚScheduledRideParticipantr²   Tr4   r   r€   r:   c                 C   s   | j j› d| jjj› �S rW   )rY   rZ   Úscheduled_ride_dayr³   r   r   r   r   r   r   ¶   s   z ScheduledRideParticipant.__str__N)r   r   r   r   r^   r±   r_   r¹   r   rY   re   rf   Ú
join_pointÚ	end_pointr†   r‰   ri   Úconfirmed_atr   r   r   r   r   r¸   ®   s    r¸   )Ú	django.dbr   Údjango.contrib.gis.dbre   Úaccounts.modelsr   r   Úvehiclehub.modelsr   r   rH   ÚModelr   r   ru   r}   rŠ   r‘   r“   r¤   r¨   r±   r¸   r   r   r   r   Ú<module>   s     '
	