
    pi                        d dl mZ d dlmZ ddlmZmZmZmZ  ej                  e       G d dej                               Z ej                  e       G d dej                               Z G d	 d
ej                        Z ej                  e       G d dej                               Z ej                  e       G d dej                               Zy)    )admin)format_html   )BrandCategoryProductProductImagec                   L    e Zd ZdZdZdZddiZdZd Zde_	        d Z
d	e
_	        y
)
BrandAdmin)namelogo_preview	is_activeproduct_count
created_at)r   r   r   slug)r   c                 \    |j                   r t        d|j                   j                        S y)NzX<img src="{}" width="40" height="40" style="object-fit: contain; border-radius: 4px;" />-)logor   urlselfobjs     '/var/www/alwasay/apps/products/admin.pyr   zBrandAdmin.logo_preview   s)    88j      Logoc                 6    |j                   j                         S Nproductscountr   s     r   r   zBrandAdmin.product_count       ||!!##r   ProductsN)__name__
__module____qualname__list_displaylist_filtersearch_fieldsprepopulated_fieldslist_editabler   short_descriptionr    r   r   r   r      s=    WL-KM!9-"M &,L"$&0M#r   r   c                   P    e Zd ZdZdZdZddiZdZdZd Z	de	_
        d	 Zd
e_
        y)CategoryAdmin)r   parentorderimage_previewr   r   r   )r   r0   r   r   r   )r   r1   )r0   c                 \    |j                   r t        d|j                   j                        S y)NzV<img src="{}" width="40" height="40" style="object-fit: cover; border-radius: 4px;" />r   imager   r   r   s     r   r2   zCategoryAdmin.image_preview%   )    99h		  r   Imagec                 6    |j                   j                         S r   r   r   s     r   r   zCategoryAdmin.product_count.   r"   r   r#   N)r$   r%   r&   r'   r(   r)   r*   r+   autocomplete_fieldsr2   r,   r   r-   r   r   r/   r/      sC    kL7KM!9-*M% '.M#$&0M#r   r/   c                   0    e Zd ZeZdZdZdZd Zde_	        y)ProductImageInliner   )r5   alt_text
is_primaryr1   r2   )r2   c                 \    |j                   r t        d|j                   j                        S yNzV<img src="{}" width="60" height="60" style="object-fit: cover; border-radius: 4px;" />r   r4   r   s     r   r2   z ProductImageInline.image_preview9   r6   r   PreviewN)
r$   r%   r&   r	   modelextrafieldsreadonly_fieldsr2   r,   r-   r   r   r;   r;   3   s%    EEJF(O '0M#r   r;   c                        e Zd ZdZdZdZdZddiZdZdZ	d	Z
d
ZegZdZdZdZ	dddifdddifdddifdddifdddifdddifddddfdddifdd ddff	Zd! Zd"e_        d# Zd$e_        d% Zd&e_         fd'Z xZS )(ProductAdmin)
r2   r   skucategorybrandprice_displaystock_statusstatusis_featuredr   )r2   r   )rL   rM   rH   rI   r   )r   rG   part_numberdescriptionr   r   )rH   rI   )rL   rM   r   )z-created_at)r2   r   rG   rH   rI   rJ   rK   rL   rM   is_top_ratedr   )rL   rM   rP   rH   rI   r   )rL   rM   rP   zBasic InformationrC   )r   r   rG   rN   Description)r,   rO   CategorizationPricing)price
sale_price	Inventory)stock_quantitylow_stock_thresholdMedia)
main_imagezVehicle Compatibility)compatible_vehicles)collapse)rC   classeszStatus & VisibilitySEO)
meta_titlemeta_descriptionc                 p    |j                   r t        d|j                   j                        S t        d      S )NzV<img src="{}" width="50" height="50" style="object-fit: cover; border-radius: 4px;" />z<div style="width: 50px; height: 50px; background: #e5e7eb; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 10px;">No Image</div>)rZ   r   r   r   s     r   r2   zProductAdmin.image_preview|   s;    >>h""   L
 	
r   r7   c                     |j                   r!t        d|j                  |j                        S t        d|j                        S )Nz<span style="text-decoration: line-through; color: #9ca3af;">AED {}</span> <span style="color: #dc2626; font-weight: bold;">AED {}</span>zAED {})
is_on_saler   rT   rU   r   s     r   rJ   zProductAdmin.price_display   s<    >>Q		3>> 
 8SYY//r   Pricec                     |j                   dk(  rt        d      S |j                  rt        d|j                         S t        d|j                         S )Nr   zD<span style="color: #dc2626; font-weight: bold;">Out of Stock</span>z@<span style="color: #f59e0b; font-weight: bold;">{} (Low)</span>z'<span style="color: #10b981;">{}</span>)rW   r   is_low_stockr   s     r   rK   zProductAdmin.stock_status   s_    "V  R""  5
 	
r   Stockc                 B    t         |   |      j                  dd      S )NrH   rI   )superget_querysetselect_related)r   request	__class__s     r   rj   zProductAdmin.get_queryset   s     w#G,;;JPPr   )r$   r%   r&   r'   list_display_linksr(   r)   r*   r9   r+   date_hierarchyorderingr;   inlines	fieldsetsr2   r,   rJ   rK   rj   __classcell__)rm   s   @r   rF   rF   C   sU   L 3NKAM!9-/-M!NH!"GL
 _K=M 
<
 	 
:
 	 
+
 	 
-
 	 
?
 	 
o
 	 
!.$#
 	 
/!
 	 
8$
 	5I@
 '.M#0 '.M#
 &-L"Q Qr   rF   c                   4    e Zd ZdZdZdZdZdZd Zde_	        y)	ProductImageAdmin)productr2   r=   r1   r   )r=   r   )product__namer<   )r=   r1   )rv   c                 \    |j                   r t        d|j                   j                        S yr?   r4   r   s     r   r2   zProductImageAdmin.image_preview   r6   r   r@   N)
r$   r%   r&   r'   r(   r)   r+   r9   r2   r,   r-   r   r   ru   ru      s+    TL.K1M+M& '0M#r   ru   N)django.contribr   django.utils.htmlr   modelsr   r   r   r	   register
ModelAdminr   r/   TabularInliner;   rF   ru   r-   r   r   <module>r      s      ) : : 1!! 1 1* 1E$$ 1 1,0,, 0  ^Q5## ^Q ^QB 0(( 0 0r   