o
    4%iH                     @   s  d dl mZ ddlmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZmZ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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!G d"d# d#ejZ"G d$d% d%ejZ#G d&d' d'ejZ$d(S ))    )serializers   )	CustomOrderTrackingOrderProductCustomizationOrdersOrderProductsAdsDiscountCouponsOrderDeliverySomeOneElse)reverse)ProductImageProductsCustomProductImage)CustomProductSerializerc                   @      e Zd ZG dd dZdS )SomeOneElseDataSerializerc                   @   s   e Zd ZeZddgZdS )zSomeOneElseDataSerializer.Metanamephone_numberN)__name__
__module____qualname__r   modelfields r   r   </var/www/html/Testing_prj/Navya-Bakers/orders/serializers.pyMeta
       r   Nr   r   r   r   r   r   r   r   r   	       r   c                   @   r   )#OrderProductCustomizationSerializerc                   @      e Zd ZeZg dZdS z(OrderProductCustomizationSerializer.Meta)idcustom_notecustom_imageNr   r   r   r   r   r   r   r   r   r   r      r   r   Nr   r   r   r   r   r!      r    r!   c                   @   sV   e Zd ZejddZejddZejddZejddZe	dddZ
G dd	 d	Zd
S )OrderProductSerializerzsku.sku_namesourcezsku.sku_quantityzsku.sku_unitz!sku.product.veg_or_non_veg_statusTmany	read_onlyc                   @   r"   )zOrderProductSerializer.Meta)skuquantitypricesku_nameveg_or_non_vegsku_quantitysku_unitcustomizationsN)r   r   r   r   r   r   r   r   r   r   r      r   r   N)r   r   r   r   	CharFieldr1   r3   r4   r2   r!   r5   r   r   r   r   r   r(      s    r(   c                       sd   e Zd ZedddZejddZejddZejddZ	e
ddZG dd	 d	Z fd
dZ  ZS )PickUpOrderSerializerTr+   store_uuid.unit_namer)   store_uuid.unit_locationstore_uuid.contact_nor-   c                   @   r"   )zPickUpOrderSerializer.Meta)uuidorder_ID
order_typeorder_status	sub_totaltaxes_and_chargesdelivery_chargesgrand_total
order_datacreated_date	shop_nameshop_locationshop_contactdelivery_slot_datedelivery_slot_timesome_one_else_orderNr   r   r   r   r   r   r   r   r   r   r   5   r   r   c                    &   t  |}|dd u ri |d< |S NrK   superto_representationgetselfinstancerepresentation	__class__r   r   rQ   I      z'PickUpOrderSerializer.to_representation)r   r   r   r(   rD   r   r6   rF   rG   rH   r   rK   r   rQ   __classcell__r   r   rW   r   r7   /   s    
r7   c                          e Zd ZedddZ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dd	ZeddZG dd dZ fddZ  ZS )OrderSerializerTr+   r8   r)   r9   r:   drop_address.address_typeFr*   
allow_nullrequired!drop_address.house_number_or_namedrop_address.land_markr;   c                   @   r"   )zOrderSerializer.Meta)r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   address_type	address_1	address_2rK   NrL   r   r   r   r   r   [   r   r   c                    rM   rN   rO   rS   rW   r   r   rQ   r   rY   z!OrderSerializer.to_representation)r   r   r   r(   rD   r   r6   rF   rG   rH   rc   rd   re   r   rK   r   rQ   rZ   r   r   rW   r   r\   R       
r\   c                   @   r   )CourierDetailsSerializerc                   @   r"   )zCourierDetailsSerializer.Meta)courier_service_namepackage_numberexpected_date_of_deliverytracking_linkN)r   r   r   r   r   r   r   r   r   r   r   y   r   r   Nr   r   r   r   r   rg   x   r    rg   c                       r[   )OrderSerializer2Tr+   zpu_uuid.pu_namer)   zpu_uuid.pu_locationzpu_uuid.contact_nor]   Fr^   ra   rb   r;   c                   @   r"   )zOrderSerializer2.Meta)r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   pu_namepu_location
pu_contactrI   rJ   rc   rd   re   rK   NrL   r   r   r   r   r      r   r   c                    rM   rN   rO   rS   rW   r   r   rQ      rY   z"OrderSerializer2.to_representation)r   r   r   r(   rD   r   r6   rm   rn   ro   rc   rd   re   r   rK   r   rQ   rZ   r   r   rW   r   rl   ~   rf   rl   c                       s   e Zd Z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ddZ
eddZeddZG dd dZ fddZ  ZS )CustomOrderCreateSerializerr8   r)   r9   r:   r]   TFr^   ra   rb   r;   c                   @   r"   )z CustomOrderCreateSerializer.Meta)r<   r=   r>   r?   r@   rA   rB   rC   rE   rF   rG   rH   rI   rJ   rc   rd   re   custom_productdescriptionmessagerK   NrL   r   r   r   r   r      r   r   c                    rM   rN   rO   rS   rW   r   r   rQ      rY   z-CustomOrderCreateSerializer.to_representation)r   r   r   r   r6   rF   rG   rH   rc   rd   re   r   rq   r   rK   r   rQ   rZ   r   r   rW   r   rp      s    

rp   c                       s   e Zd Z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ddZ
eddZeddZe Ze Ze Ze Ze Ze ZG dd dZdd Zdd Zdd Zdd Zdd Zdd Z fddZ  ZS )CustomOrderSerializerr8   r)   r9   r:   r]   TFr^   ra   rb   r;   c                   @   r"   )zCustomOrderSerializer.Meta)r<   r=   r>   r?   r@   rA   rB   rC   discountrE   rF   rG   rH   rI   rJ   rc   rd   re   rq   rr   rs   rK   r&   r/   quantity_unitdelivery_typelatitude	longitudeNrL   r   r   r   r   r      r   r   c                 C   sH   zt jj|d}|jr| jd |jjW S W d S  t jy#   Y d S w )Norder_idrequest)r   objectsrR   r&   contextbuild_absolute_uriurlDoesNotExistrT   objcustom_trackingr   r   r   get_custom_image  s   z&CustomOrderSerializer.get_custom_imagec                 C   .   zt jj|d}|jW S  t jy   Y d S w Nrz   )r   r}   rR   r/   r   r   r   r   r   get_quantity     z"CustomOrderSerializer.get_quantityc                 C   r   r   )r   r}   rR   rv   r   r   r   r   r   get_quantity_unit  r   z'CustomOrderSerializer.get_quantity_unitc                 C   r   r   )r   r}   rR   rw   r   r   r   r   r   get_delivery_type  r   z'CustomOrderSerializer.get_delivery_typec                 C   F   zt jj|d}|jdkr|jr|jjW S W d S  t jy"   Y d S w Nrz   zPick Up)r   r}   rR   rw   drop_addressrx   r   r   r   r   r   get_latitude&     
z"CustomOrderSerializer.get_latitudec                 C   r   r   )r   r}   rR   rw   r   ry   r   r   r   r   r   get_longitude0  r   z#CustomOrderSerializer.get_longitudec                    rM   rN   rO   rS   rW   r   r   rQ   :  rY   z'CustomOrderSerializer.to_representation)r   r   r   r   r6   rF   rG   rH   rc   rd   re   r   rq   r   rK   SerializerMethodFieldr&   r/   rv   rw   rx   ry   r   r   r   r   r   r   r   rQ   rZ   r   r   rW   r   rt      s.    

!	

rt   c                   @   r   )r!   c                   @   r"   r#   r'   r   r   r   r   r   K  r   r   Nr   r   r   r   r   r!   J  r    c                       s   e Zd Ze Ze ZejdddZ	e
 Ze Ze Ze Ze ZejddddZG dd dZdd	 Zd
d Z fddZ  ZS )PastOrderListSerializerFT)r`   r_   r]   r^   c                   @   r"   )zPastOrderListSerializer.Meta)r<   r=   rI   rJ   rC   r?   r>   product_namesproduct_imagerc   rr   NrL   r   r   r   r   r     r   r   c                 C   s(   |j dkr
|jjgS dd |j D S )NCustom Ordersc                 S   s   g | ]}|j qS r   )product_name).0order_productr   r   r   
<listcomp>  s    z=PastOrderListSerializer.get_product_names.<locals>.<listcomp>)r>   rq   	item_namerD   all)rT   r   r   r   r   get_product_names  s   

z)PastOrderListSerializer.get_product_namesc                 C   sd   |j dkrtjj|jd }|r|jjS |j	 D ]}t
jj|jjd }|r/|jj  S qd S )Nr   )rq   )product)r>   r   r}   filterrq   firstimager   rD   r   r   r.   r   )rT   r   product_image_customr   r   r   r   r   get_product_image  s$   
z)PastOrderListSerializer.get_product_imagec                    s"   t  |}|dsd|d< |S )NrJ   zNot ProvidedrO   )rT   rU   datarW   r   r   rQ     s   
z)PastOrderListSerializer.to_representation)r   r   r   r   r6   r=   	DateFieldrI   	TimeFieldrJ   
FloatFieldrC   r?   r>   r   r   r   rc   r   r   r   rQ   rZ   r   r   rW   r   r     s    r   c                   @   r   )ProductSerializerc                   @   r"   )zProductSerializer.Meta)r$   r   	item_codeN)r   r   r   r   r   r   r   r   r   r   r     r   r   Nr   r   r   r   r   r     r    r   c                   @   r   )CouponSerializerc                   @   r"   )zCouponSerializer.Meta)r$   
CouponName
CouponCodeN)r   r   r   r
   r   r   r   r   r   r   r     r   r   Nr   r   r   r   r   r     r    r   c                   @   r   )DiscountSerializerc                   @   r"   )zDiscountSerializer.Meta)r$   DiscountNameDiscountCodeNr   r   r   r	   r   r   r   r   r   r   r     r   r   Nr   r   r   r   r   r     r    r   c                   @   s\   e Zd Ze Ze Ze Ze Ze	 Z
e	 Ze Ze Ze ZG dd dZdS )AdSerializerc                   @   r"   )zAdSerializer.Meta)	AdTitleAdDescriptionAdPlacementAdTypeStandardImageBannerImager	   CouponProductN)r   r   r   r   r   r   r   r   r   r   r     r   r   N)r   r   r   r   r6   r   r   r   r   
ImageFieldr   r   r   r	   r   r   r   r   r   r   r   r   r   r     s    r   c                   @   r   )DiscountDetailSerializerc                   @   r"   )zDiscountDetailSerializer.Meta)r$   r   r   DiscountDescription
DiscountOnApplicableCategoryApplicableSubCategoryApplicableProductApplicableSkuDiscountPercentager   r   Nr   r   r   r   r   r     r   r   Nr   r   r   r   r   r     r    r   c                   @   r   )OrderBillDetailsSerializerc                   @   r"   )zOrderBillDetailsSerializer.Meta)r@   rA   rB   rC   total_savingscoupon_savingsru   NrL   r   r   r   r   r     r   r   Nr   r   r   r   r   r     r    r   N)%rest_frameworkr   modelsr   r   r   r   r   r	   r
   r   r   django.urlsr   products.modelsr   r   r   products.serializersr   ModelSerializerr   r!   r(   r7   r\   rg   rl   rp   rt   r   r   r   r   r   r   r   r   r   r   r   <module>   s,    ,#&&/wA7