
    vg                         d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZ e	dd       Ze	d        Ze	d	        Ze	d
        Zy)zq
offboarding/decorators.py

This module is used to write custom authentication decorators for offboarding module
    )messages)HttpResponseHttpResponseRedirect)render)decorator_with_arguments)OffboardingOffboardingGeneralSettingOffboardingStageOffboardingTaskc                       fd}|S )Nc                 H   | 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managersHTTP_REFERER/ <script>window.location.href = "
"</script>HTTP_HX_REQUESTdecorator_404.html)useremployee_gethas_permr   objectsfilterexistsr
   r   METAgetkeysr   r   )
requestargskwargsemployeeprevious_urlscriptkeyfunctionoffboarding_employee_can_enterperms
          */var/www/horilla/offboarding/decorators.py	_functionz(any_manager_can_enter.<locals>._function   s   <<,,LL!!$'-##**H*=DDF"**1181DKKMN!))00(0CJJLM
 G5d5f55"<<++NC@L7~ZPF#Cgll''))g';<<''     )r&   r(   r'   r*   s   ``` r)   any_manager_can_enterr-      s    (( r+   c                       fd}|S )Nc                    | 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   You dont have permission.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(   s	          r)   r*   z0offboarding_manager_can_enter.<locals>._function/   s    <<,,LL!!$'""))8)<CCEG5d5f55MM'#>?"<<++NC@L7~ZPF#Cgll''))g';<<''r+   r,   r&   r(   r*   s   `` r)   offboarding_manager_can_enterr3   -   s    (  r+   c                       fd}|S )Nc                    | 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   r0   r   r   r   r   r   r   )r   r   r   r   r   r   r   r
   r   r1   r   r   r   r   r   )	r   r    r!   r"   r#   r%   r$   r&   r(   s	          r)   r*   z9offboarding_or_stage_manager_can_enter.<locals>._functionD   s    <<,,LL!!$'""))8)<CCE''...AHHJG5d5f55MM'#>?"<<++NC@L#Cgll''))g';<<7~ZPF''r+   r,   r2   s   `` r)   &offboarding_or_stage_manager_can_enterr6   B   s    (" r+   c                       fd}|S )Nc                 P   t         j                  j                         }t        |d      }|r 	| g|i |S t	        j
                  | d       | j                  j                  dd      }d}|| j                  j                         v rt        | d      S d| d}t        |      S )	NFz&Feature is not enabled on the settingsr   r   r   r   r   r   )r	   r   firstgetattrr   r1   r   r   r   r   r   )
r   r    r!   general_settingenabledr#   r%   r$   feature_namer&   s
           r)   r*   z(check_feature_enabled.<locals>._functionZ   s    3;;AAC/<?G5d5f55gGH||''<',,##%%'#7883L>LF##r+   r,   )r&   r=   r*   s   `` r)   check_feature_enabledr>   X   s    $ r+   N)F)__doc__django.contribr   django.httpr   r   django.shortcutsr   horilla.decoratorsr   offboarding.modelsr   r	   r
   r   r-   r3   r6   r>   r,   r+   r)   <module>rE      sr    $ : # 7   0  (  *  r+   