o
    6k~i
                     @   s^   d dl mZ d dlmZ d dlm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)gettext_lazy)MinValueValidatorc                   @   s0   e Zd ZdedfZdedfZdedfZdS )BookingTypetableTableappointmentAppointmentsimpleSimpleN)__name__
__module____qualname___TABLEAPPOINTMENTSIMPLE r   r   4/var/www/newdalilibackend/backend/bookings/models.pyr      s    r   c                   @   s<   e Zd ZdedfZdedfZdedfZdedfZd	S )
BookingStatuspendingPending	confirmed	Confirmed	cancelled	Cancelled	completed	CompletedN)r   r   r   r   PENDING	CONFIRMED	CANCELLED	COMPLETEDr   r   r   r   r      s
    r   c                   @   s  e Zd ZdZejdejdeddZejdejdeddZ	ej
dejejed	d
ZejeddZejeddZejddedgeddZejddeddZej
dejejedd
ZejddZejddZG dd dZdd Ze dd Z!e dd Z"e dd  Z#d!S )"BookingzBooking Modelzplaces.PlacebookingsPlace)	on_deleterelated_nameverbose_namezaccounts.UserUser   Type)
max_lengthchoicesdefaultr'   Date)r'   TimeT   zNumber of Guests)blanknull
validatorsr'   zSpecial Requests)r1   r2   r'   Status)auto_now_add)auto_nowc                   @   sL   e Zd ZedZedZdgZejddgdejdgdejdgdgZ	d	S )
zBooking.Metar"   Bookingsz-created_atplacedate)fieldsuserstatusN)
r   r   r   r   r'   verbose_name_pluralorderingr   Indexindexesr   r   r   r   Meta9   s    rA   c                 C   s   | j j d| jj d| j S )Nz - )r;   usernamer8   namer9   selfr   r   r   __str__C   s   zBooking.__str__c                 C   s<   ddl m} ||j| j| j}|| ko| jt	j
kS Nr   )timezone)django.utilsrH   
make_awaredatetimecombiner9   timenowr<   r   r    rE   rH   booking_datetimer   r   r   is_upcomingF   
   zBooking.is_upcomingc                 C   s<   ddl m} ||j| j| j}|| k p| jt	j
kS rG   )rI   rH   rJ   rK   rL   r9   rM   rN   r<   r   r!   rO   r   r   r   is_pastN   rR   zBooking.is_pastc                 C   s   | j tjtjfv S )N)r<   r   r   r   rD   r   r   r   
can_cancelV   s   zBooking.can_cancelN)$r   r   r   __doc__r   
ForeignKeyCASCADEr   r8   r;   	CharFieldr   r,   r   type	DateFieldr9   	TimeFieldrM   IntegerFieldr   number_of_guests	TextFieldspecial_requestsr   r   r<   DateTimeField
created_at
updated_atrA   rF   propertyrQ   rS   rT   r   r   r   r   r"      sZ    


r"   N)	django.dbr   django.utils.translationr   r   django.core.validatorsr   TextChoicesr   r   Modelr"   r   r   r   r   <module>   s    