o
    +g"                      @   s0  d dl mZ ddlmZmZmZmZmZmZ d dl	m
Z
 d dl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dS )     )serializers   )OrdersOrderProductsAdsDiscountCouponsOrderDelivery)reverse)ProductImageProducts)CustomProductSerializerc                   @   sJ   e Zd ZejddZejddZejddZej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_statusc                   @      e Zd ZeZg dZdS )zOrderProductSerializer.Meta)skuquantitypricesku_nameveg_or_non_vegsku_quantitysku_unitN)__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   	CharFieldr   r   r   r   r    r   r   r   r   r   	   s    r   c                   @   z   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G dd dZdS )OrderSerializerTmany	read_onlystore_uuid.unit_namer   store_uuid.unit_locationstore_uuid.contact_nodrop_address.address_typeFr   
allow_nullrequired!drop_address.house_number_or_namedrop_address.land_markc                   @   r   )zOrderSerializer.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address_type	address_1	address_2descriptionmessageNr   r   r   r   r   r   r   r   r   r   r    $   r!   r    N)r   r   r   r   r9   r   r"   r;   r<   r=   r@   rA   rB   r    r   r   r   r   r$          r$   c                   @      e Zd ZG dd dZdS )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    >   r!   r    Nr   r   r   r    r   r   r   r   rH   =       rH   c                   @   r#   )OrderSerializer2Tr%   zpu_uuid.pu_namer   zpu_uuid.pu_locationzpu_uuid.contact_nor+   Fr,   r/   r0   c                   @   r   )zOrderSerializer2.Meta)r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   pu_namepu_location
pu_contactr>   r?   r@   rA   rB   NrE   r   r   r   r   r    K   r!   r    N)r   r   r   r   r9   r   r"   rP   rQ   rR   r@   rA   rB   r    r   r   r   r   rO   C   rF   rO   c                   @   s   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dS )CustomOrderSerializerTr%   r(   r   r)   r*   r+   Fr,   r/   r0   )r'   c                   @   r   )zCustomOrderSerializer.Meta)r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   custom_productrC   rD   NrE   r   r   r   r   r    k   r!   r    N)r   r   r   r   r9   r   r"   r;   r<   r=   r@   rA   rB   r   rT   r    r   r   r   r   rS   b   s    
rS   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)
r1   r2   r>   r?   r8   r4   r3   product_namesproduct_imager@   NrE   r   r   r   r   r       r!   r    c                 C   s   dd |j  D S )Nc                 S   s   g | ]}|j qS r   )product_name).0order_productr   r   r   
<listcomp>   s    z=PastOrderListSerializer.get_product_names.<locals>.<listcomp>)r9   all)selfobjr   r   r   get_product_names   s   z)PastOrderListSerializer.get_product_namesc                 C   s:   |j  D ]}tjj|jjd }|r|jj	  S qd S )N)product)
r9   r\   r   objectsfilterr   r`   firstimageurl)r]   r^   rZ   rW   r   r   r   get_product_image   s   z)PastOrderListSerializer.get_product_imagec                    s"   t  |}|dsd|d< |S )Nr?   zNot Provided)superto_representationget)r]   instancedata	__class__r   r   rh      s   
z)PastOrderListSerializer.to_representation)r   r   r   r   r"   r2   	DateFieldr>   	TimeFieldr?   
FloatFieldr8   r4   r3   SerializerMethodFieldrV   rW   r@   r    r_   rf   rh   __classcell__r   r   rl   r   rU      s    	rU   c                   @   rG   )ProductSerializerc                   @   r   )zProductSerializer.Meta)id	item_name	item_codeN)r   r   r   r   r   r   r   r   r   r   r       r!   r    NrM   r   r   r   r   rs      rN   rs   c                   @   rG   )CouponSerializerc                   @   r   )zCouponSerializer.Meta)rt   
CouponName
CouponCodeN)r   r   r   r   r   r   r   r   r   r   r       r!   r    NrM   r   r   r   r   rw      rN   rw   c                   @   rG   )DiscountSerializerc                   @   r   )zDiscountSerializer.Meta)rt   DiscountNameDiscountCodeNr   r   r   r   r   r   r   r   r   r   r       r!   r    NrM   r   r   r   r   rz      rN   rz   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   r"   r   r   r   r   
ImageFieldr   r   rz   r   rw   r   rs   r   r    r   r   r   r   r~      s    r~   c                   @   rG   )DiscountDetailSerializerc                   @   r   )zDiscountDetailSerializer.Meta)rt   r{   r|   DiscountDescription
DiscountOnApplicableCategoryApplicableSubCategoryApplicableProductApplicableSkuDiscountPercentager   r   Nr}   r   r   r   r   r       r!   r    NrM   r   r   r   r   r      rN   r   c                   @   rG   )OrderBillDetailsSerializerc                   @   r   )zOrderBillDetailsSerializer.Meta)r5   r6   r7   r8   total_savingscoupon_savingsdiscountNrE   r   r   r   r   r       r!   r    NrM   r   r   r   r   r      rN   r   N)rest_frameworkr   modelsr   r   r   r   r   r	   django.urlsr
   products.modelsr   r   products.serializersr   ModelSerializerr   r$   rH   rO   rS   rU   rs   rw   rz   r~   r   r   r   r   r   r   <module>   s"     !&.