o
    iJ                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ G dd dZG d	d
 d
ZG dd dZG dd dZdS )z
View Mixins for Web Interface
    )login_required)method_decorator)redirect)settings)CategoryGovernoratec                       s.   e Zd ZdZeedd fddZ  ZS )LoginRequiredMixinz Mixin to require login for viewsz/login/)	login_urlc                    s   t  j|i |S )N)superdispatch)selfargskwargs	__class__ 2/var/www/newdalilibackend/backend/config/mixins.pyr      s   zLoginRequiredMixin.dispatch)__name__
__module____qualname____doc__r   r   r   __classcell__r   r   r   r   r      s    r   c                       s    e Zd ZdZ fddZ  ZS )PlaceContextMixinz)Mixin to add common place-related contextc                    sT   t  jd	i |}tjjddd|d< tj d|d< tj	|d< d|d< |S )
NT)	is_activename_ar
categoriesgovernorates	media_urlz/apiapi_base_urlr   )
r
   get_context_datar   objectsfilterorder_byr   allr   	MEDIA_URL)r   r   contextr   r   r   r      s   
z"PlaceContextMixin.get_context_data)r   r   r   r   r   r   r   r   r   r   r      s    r   c                   @   s   e Zd ZdZdZdZdS )PaginationMixinzMixin for pagination      N)r   r   r   r   paginate_bypaginate_orphansr   r   r   r   r&      s    r&   c                   @   s   e Zd ZdZdd ZdS )FilterMixinz!Mixin for filtering and searchingc              	   C   sZ   | j jdd| j jdd| j jdd| j jdd| j jdd| j jdddS )	z&Extract filter parameters from requestsearch categorygovernorate
min_ratingis_openhas_booking)r,   r.   r/   r0   r1   r2   )requestGETget)r   r   r   r   get_filter_params%   s   zFilterMixin.get_filter_paramsN)r   r   r   r   r6   r   r   r   r   r+   #   s    r+   N)r   django.contrib.auth.decoratorsr   django.utils.decoratorsr   django.shortcutsr   django.confr   places.modelsr   r   r   r   r&   r+   r   r   r   r   <module>   s    