o
    Ii                     @   sH   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 edd Z
dS )	z
Favorites Views
    )render)login_required_web)Favorite)CountAvgc                 C   s   t jj| jdddddjtdtdd	d}g }|D ] }|j
}t|d	s0|jp.d
|_t|ds;|jp9d
|_|| q dd|t|d}t| d|S )zUser favorites list)userplaceplace__categoryplace__governorateplace__reviewsplace__reviews__rating)reviews_count
avg_ratingz-created_atr   r   ratingu   المفضلة - دليلك IQu&   الأماكن المفضلة لديك)titledescriptionplacesfavorites_countzfavorites/list.html)r   objectsfilterr   select_relatedprefetch_relatedannotater   r   order_byr   hasattrr   r   r   appendlenr   )request	favoritesr   favoriter   context r!   ;/var/www/newdalilibackend/backend/config/views/favorites.pyfavorites_view
   s>   

r#   N)__doc__django.shortcutsr   config.decoratorsr   notifications.modelsr   django.db.modelsr   r   r#   r!   r!   r!   r"   <module>   s    