| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/erp/onboarding/__pycache__/ |
Upload File : |
o
hͦh� � @ s� d Z ddlmZ ddlmZmZ ddlmZ ddlm Z ddl
mZmZ ddl
mZ dd � Zed
d� �Zedd
� �Zedd� �ZdS )zX
decorators.py
Custom decorators for permission and manager checks in the application.
� )�messages)�HttpResponse�HttpResponseRedirect)�render)�Employee)�OnboardingStage�OnboardingTask)�Recruitmentc s � fdd�}|S )z�
Decorator that allows decorators to accept arguments and keyword arguments.
Args:
decorator (function): The decorator function to be wrapped.
Returns:
function: The wrapper function.
c s � ��fdd�}|S )a
Wrapper function that captures the arguments and keyword arguments.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
function: The inner wrapper function.
c s �| g� �R i ���S )z�
Inner wrapper function that applies the decorator to the function.
Args:
func (function): The function to be decorated.
Returns:
function: The decorated function.
� )�func)�args� decorator�kwargsr
�%/var/www/erp/onboarding/decorators.py�
inner_wrapper) s z@decorator_with_arguments.<locals>.wrapper.<locals>.inner_wrapperr
)r r r �r
)r r r �wrapper s
z)decorator_with_arguments.<locals>.wrapperr
)r
r r
r r �decorator_with_arguments s r c � � �fdd�}|S )�W
This method is used to check permission of employee for enter to the function
c s� | j }tjj|d��� }tjj|d��� p$tjj|d�p$tjj|d��� }|� ��s,|r7� | g|�R i |��S t
�| d� | j�
dd�}d|� d�}d }|| j�� v rXt| d
�S t|�S �N��employee_user_id)�employee_id��recruitment_managers�You dont have permission.�HTTP_REFERER�/� <script>window.location.href = "�
"</script>�HTTP_HX_REQUEST�decorator_404.html)�userr �objects�filter�firstr �existsr r �has_permr �info�META�get�keysr r � �requestr r r# �employee�
is_manager�previous_url�script�key��function�permr
r � _functionA s ��
z(all_manager_can_enter.<locals>._functionr
�r5 r6 r7 r
r4 r �all_manager_can_enter; s r9 c r )r c s� | j }tjj|d��� }tjj|d�ptjj|d��� }|���s#|r.� | g|�R i |��S t �
| d� | j�dd�}d|� d�}d }|| j�
� v rOt| d
�S t|�S r )r# r r$ r% r&