o
    ^"<fÉ  ã                   @   sD   d dl mZ d dlmZ d dlmZ ddlmZ G dd„ deƒZdS )	é    )Úsettings)ÚHttpResponse)ÚMiddlewareMixiné   )Úget_view_namec                   @   s   e Zd ZdZdd„ ZdS )ÚXViewMiddlewarez9
    Add an X-View header to internal HEAD requests.
    c                 C   sb   t |dƒs	J dƒ‚|jdkr+|j d¡tjv s|jjr-|jjr/t	ƒ }t
|ƒ|jd< |S dS dS dS )a  
        If the request method is HEAD and either the IP is internal or the
        user is a logged-in staff member, return a response with an x-view
        header indicating the view function. This is used to lookup the view
        function for an arbitrary page.
        ÚuserzªThe XView middleware requires authentication middleware to be installed. Edit your MIDDLEWARE setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware'.ÚHEADÚREMOTE_ADDRzX-ViewN)ÚhasattrÚmethodÚMETAÚgetr   ÚINTERNAL_IPSr   Ú	is_activeÚis_staffr   r   Úheaders)ÚselfÚrequestÚ	view_funcÚ	view_argsÚview_kwargsÚresponse© r   úZ/var/www/html/kck/venv/lib/python3.10/site-packages/django/contrib/admindocs/middleware.pyÚprocess_view   s   ÿÿÿüzXViewMiddleware.process_viewN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   N)	Údjango.confr   Údjango.httpr   Údjango.utils.deprecationr   Úutilsr   r   r   r   r   r   Ú<module>   s
    