
    si                         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	 d dl
mZmZmZ edd       Zed        Zed	        Zy
)    )messages)HttpResponse)render)decorator_with_arguments)_thread_locals)OffboardingOffboardingStageOffboardingTaskc                       fd}|S )Nc                    t        t        d      }t        | dd       s|| _        |j                  j                  }|j                  j                  
      s	st        j                  j                  |      j                         t        j                  j                  |      j                         z  t        j                  j                  |      j                         z  r | g|i |S |j                  j                  dd      }d| d}d}||j                  j                         v rt        | d      S t!        |      S )	NrequestmanagersHTTP_REFERER/ <script>window.location.href = "
"</script>HTTP_HX_REQUESTdecorator_404.html)getattrr   r   useremployee_gethas_permr   objectsfilterexistsr	   r
   METAgetkeysr   r   )selfargskwargsr   employeeprevious_urlscriptkeyfunctionoffboarding_employee_can_enterperms           >/var/www/python-projects/worksol/offboarding/cbv_decorators.py	_functionz(any_manager_can_enter.<locals>._function   s    .)4tY-"DL<<,,LL!!$'-##**H*=DDF"**1181DKKMN!))00(0CJJLM
 D242622"<<++NC@L7~ZPF#Cgll''))d$899''     )r'   r)   r(   r+   s   ``` r*   any_manager_can_enterr.   
   s    (. r,   c                       fd}|S )Nc                    t        t        d      }t        | dd       s|| _        |j                  j	                  	      }|j                  j	                  	      s.t
        j                  j                  |      j                         r | g|i |S t        j                  |d       |j                  j                  dd      }d| d}d}||j                  j                         v rt        | d	      S t        |      S )
Nr   r   You dont have permission.r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   infor   r   r   r   r   )
r    r!   r"   r   r#   r$   r%   r&   r'   r)   s
           r*   r+   z0offboarding_manager_can_enter.<locals>._function(   s    .)4tY-"DL<<((.LL!!$'""))8)<CCED242622MM'#>?"<<++NC@L7~ZPF#Cgll''))d$899''r,   r-   r'   r)   r+   s   `` r*   offboarding_manager_can_enterr4   &   s    (& r,   c                       fd}|S )Nc                 b   t        t        d      }t        | dd       s|| _        |j                  j	                  	      }|j                  j	                  	      s\t
        j                  j                  |      j                         s.t        j                  j                  |      j                         r | g|i |S t        j                  |d       |j                  j                  dd      }d}||j                  j                         v rt        |d      S d| d	}t!        |      S )
Nr   r   r1   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r	   r   r2   r   r   r   r   r   )
r    r!   r"   r   r#   r$   r&   r%   r'   r)   s
           r*   r+   z9offboarding_or_stage_manager_can_enter.<locals>._function@   s   .)4tY-"DL<<((.LL!!$'""))8)<CCE''...AHHJD242622MM'#>?"<<++NC@L#Cgll''))g';<<7~ZPF''r,   r-   r3   s   `` r*   &offboarding_or_stage_manager_can_enterr7   >   s    (( r,   N)F)django.contribr   django.httpr   django.shortcutsr   horilla.decoratorsr   horilla.horilla_middlewaresr   offboarding.modelsr   r	   r
   r.   r4   r7   r-   r,   r*   <module>r>      sV    # $ # 7 6 M M  6  .  r,   