U
    {he                     @   s   d dl mZ d dlmZmZ d dlmZm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 d	d
 Zdd ZdS )    )settings)Http404HttpResponse)get_object_or_404redirect)reverse)url_has_allowed_host_and_scheme)hooks)PasswordViewRestrictionForm)PagePageViewRestrictionc                 C   sf   t | |}|d krtn
|\}}}tdD ]$}||| ||}t|tr.|  S q.|j| f||S )NZbefore_serve_page)r   Zroute_for_requestr   r	   Z	get_hooks
isinstancer   serve)requestpathZroute_resultpageargskwargsfnresult r   U/var/www/dating/data/www/fatepal.com/env/lib/python3.8/site-packages/wagtail/views.pyr      s    


r   c                 C   s   t t|d}t t|dj}| jdkrrt| j|d}| r||jd }t	|| 
 |  s^tj}||  t|S n
t|d}td|j|jgd}|| ||S )z
    Handle a submission of PasswordViewRestrictionForm to grant view access over a
    subtree that is protected by a PageViewRestriction
    )idPOST)instance
return_urlZ&wagtailcore_authenticate_with_password)r   )r   r   r   Zspecificmethodr
   r   Zis_validZcleaned_datar   get_hostZ	is_securer   ZLOGIN_REDIRECT_URLZmark_as_passedr   r   r   Z serve_password_required_response)r   Zpage_view_restriction_idZpage_idZrestrictionr   formr   Z
action_urlr   r   r   authenticate_with_password   s(    

  


 
r   N)Zdjango.confr   Zdjango.httpr   r   Zdjango.shortcutsr   r   Zdjango.urlsr   Zdjango.utils.httpr   Zwagtailr	   Zwagtail.formsr
   Zwagtail.modelsr   r   r   r   r   r   r   r   <module>   s   