403Webshell
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/offboarding/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/offboarding/__pycache__/views.cpython-310.pyc
o

hͦhT��@s�ddlZddlmZmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZmZdd
lmZddlmZddlmZdd
lmZmZmZmZddlm Z ddl!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'ddl(m)Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKigfdd�ZLdd�ZMe%e0ddd�dd ���ZNe%e$e0ddd�d!d"����ZOe%e$e'd#�d$d%����ZPe%e'd&�d'd(���ZQe%e2d)�d*d+���ZRe%e0d,�d-d.���ZSe%e'd/�d0d1���ZTe%e'd2�d3d4���ZUe%e$e0d5�d6d7����ZVe%e$e0d8dd�dhd9d:����ZWe%d;d<��ZXe%e&d=d>�d?d@���ZYe%e'dA�dBdC���ZZe%e3dD�dEdF���Z[e%e0dGdd�dHdI���Z\e%e0dJ�dKdL���Z]e%e3dM�dNdO���Z^e%e$dPdQ���Z_e%e'dR�e1dS�dTdU����Z`e%e'dR�dVdW���Zae%e$e1dS�dXdY����Zbe%e1dS�dZd[���Zce%e$e1dS�d\d]����Zde%e1dS�e'd^�d_d`����Zee%e$e'da�dbdc����Zfe%e'd,�ddde���Zgdfdg�ZhdS)i�N)�datetime�	timedelta)�parse_qs)�apps)�messages)�User)�	Paginator)�HttpResponse�JsonResponse)�redirect�render)�reverse)�gettext_lazy)�intial_notice_period)�closest_numbers�
eval_validate�
paginator_qry�sortby)�general_settings)�Employee)�hx_request_required�login_required�manager_can_enter�permission_required)�group_by_queryset)�get_horilla_model_class)�notify)�any_manager_can_enter�check_feature_enabled�offboarding_manager_can_enter�&offboarding_or_stage_manager_can_enter)�LetterFilter�
LetterReGroup�PipelineEmployeeFilter�PipelineFilter�PipelineStageFilter)�NoteForm�OffboardingEmployeeForm�OffboardingForm�OffboardingStageForm�ResignationLetterForm�StageSelectForm�TaskForm)	�EmployeeTask�Offboarding�OffboardingEmployee�OffboardingGeneralSetting�OffboardingNote�OffboardingStage�OffboardingStageMultipleFile�OffboardingTask�ResignationLettercCs4g}|D]�}g}t||j��d�j�d�}g}|ggd�}|D]B}|�|gd��t|tjj	|dd��j�d�}	d|j
t|j�}
t
|	d	|�|
�|
�j}|d
d�|j��D�}|d||d<qg}|d}
|D]!}d
}|
D]}|d|kr�|�|�d}nqp|s�|�d|i�qj|||d�}|�|�q|S)N)�queryset�id)�offboarding�stages�	employees)�grouper�listT)�stage_id�employee_id__is_active�stage_id__id�pager=cS�g|]}|j�qS��r7��.0�employeerBrB�!/var/www/erp/offboarding/views.py�
<listcomp>W��z$pipeline_grouper.<locals>.<listcomp>r9Fr;)r8r9�employee_ids)r%�offboardingstage_set�all�qs�order_by�appendr#r/�objects�filter�title�strr7�group_by�get�object_list�offboardingemployee_set)�filters�offboardings�groupsr8r:r9�all_stages_grouper�data�stage�stage_employees�	page_name�employee_grouper�ordered_data�groupers�foundr;rBrBrG�pipeline_grouper>sh
��������
���rdcCst|d�}|�|�}|S)zA
    This method is used to generate common paginator limit.
    �)r�get_page)�qryset�page_number�	paginatorrBrBrG�!paginator_qry_offboarding_limitedss

rjzoffboarding.view_offboardingT)�offboarding_employee_can_entercCs�t�j}t||j�d��}ti|�}|D]}t|dd|d�qi}|D]}t|d�|t|j	�<q%t
|j���}t|d||t
�t�t�||t����d��S)z#
    Offboarding pipeline view
    r@r8r9�r8z"offboarding/pipeline/pipeline.html)rY�paginated_offboardings�employee_filter�pipeline_filter�stage_filter�stage_forms�filter_dict�today)r$rMrj�GETrUrd�setattrr+rSr7r�	urlencoderr#r%rrs�date)�requestrYrmrZ�itemrqr8rrrBrBrG�pipeline|s0	�

��rzc	Cs�t|j�j}t||j�d��}t|j|�}|D]}t|dd|d�qi}|D]}t|d�|t|j	�<q(t
|d|||t|j���d��S)z8
    This method is used filter offboarding process
    r@r8r9rlz&offboarding/pipeline/offboardings.html)rYrmrqrr)
r$rtrMrjrUrdrur+rSr7rrrv)rxrYrmrZryrqr8rBrBrG�filter_pipeline�s&	���r{zoffboarding.add_offboardingcCs�tt|j�d���}d}|rt|t�rtjj|d��	�}t
|d�}|jdkr]t
|j|d�}|�
�r]|��}t�|td��dd�|j��D�}tj|jj|d	d
ddd
dtd�d�	td�St|dd|i�S)z!
    Create offboarding view
    �instance_idNrC��instance�POSTzOffboarding savedcSrArB��employee_user_idrDrBrBrGrH�rIz&create_offboarding.<locals>.<listcomp>z(You are chosen as an offboarding manageruAلقد تم اختيارك كمدير عملية المغادرةu.Sie wurden als Offboarding-Manager ausgewähltz,Has sido elegido como gerente de offboardingu@Vous avez été choisi comme responsable du processus de départ�
people-circle�offboarding-pipeline��	recipient�verb�verb_ar�verb_de�verb_es�verb_fr�iconr�)<script>window.location.reload()</script>zoffboarding/pipeline/form.html�form)rrSrtrU�
isinstance�intr.rPrQ�firstr(�methodr�is_valid�saver�success�_�managersrLr�send�user�employee_getr
r	r)rxr|r~r��off_boarding�usersrBrBrG�create_offboarding�s>

����r�zoffboarding.delete_offboardingc	Cs`ztjj|d�}|��t�|td��Wt
t�Stjtfy/t�	|td��Yt
t�Sw)z4
    This method is used to delete offboardings
    rCzOffboarding deletedzOffboarding not found)r.rPrU�deleterr�r��DoesNotExist�
OverflowError�errorrr{)rxr7r8rBrBrG�delete_offboarding�s��r�z offboarding.add_offboardingstagecCs|jd}tt|j�d���}d}|rt|t�rtjj|d�}tjj|d�}t	|d�}||j
_|jdkr~t	|j
|d�}|��r~|jdd�}||_|��|j�|j�d	��t�|td
��dd�|j��D�}tj|jj|d
dddddtd�d�	td�St|dd|i�S)z?
    This method is used to create stages for offboardings
    �offboarding_idr|NrCr}rF��commitr�zStage savedcSrArBr�rDrBrBrGrH�z create_stage.<locals>.<listcomp>z+You are chosen as offboarding stage manageruNلقد تم اختيارك كمدير لمرحلة عملية المغادرةu8Sie wurden als Manager der Offboarding-Phase ausgewähltz8Has sido elegido como gerente de la etapa de offboardingu?Vous avez été choisi comme responsable de l'étape de départr�r�r�r�zoffboarding/stage/form.htmlr�)rtrrSrUr�r�r2rPr.r)r~r�r�rr�r�r��setr\�getlistrr�r�rLrr�r�r�r
r	r)rxr�r|r~r8r�r�rBrBrG�create_stages<


�r�z#offboarding.add_offboardingemployeecCsjt|�drt|�dnd}t��t|d�}|jd}tt|j�d���}d}|r6t|t	�r6t
jj|d�}tjj|d�}t
||d�|d	�}||j_|jd
kr�t
|j|d�}|��r�|jdd
�}||_|��t�|td��|s�tj|jj|jjd|�d|j��d|�d|j��d|�d|j�d�d|�d|j��d|�d|j��td�dd�	td�St |dd|i�S)z:
    This method is used to add employee to the stage
    �get_initial_notice_periodr��daysr=r|NrC)r=�notice_period_ends��initialr~rr}Fr�zEmployee savedzYou have been added to the z of u"لقد تمت إضافتك إلى u من zDu wurdest zu z von u
 hinzugefügtuHas sido añadido a z de uVous avez été ajouté à r��information�r�r�r�r�r�r�rr�r�zoffboarding/employee/form.htmlr�)!rrrsrrtrrSrUr�r�r/rPr2r'r~r=r�rr�r�rr�r�rr�r�r��employee_idr�r�r
r	r)rx�default_notice_period�end_dater=r|r~r]r�rBrBrG�add_employee&sH
��

�
�r�z&offboarding.delete_offboardingemployeecCs�|j�d�}tjj|d�}|r;|��t�|td��t	j
|jjt
jj|jddd�d�ddd	d
dtd�d
d�	tt�St�|td��tt�S)z@
    This method is used to delete the offboarding employee
    rJ��id__inzOffboarding employee deleted�employee_id__employee_user_idT��flatz*You have been removed from the offboardingu7لقد تمت إزالتك من إنهاء الخدمةz'Du wurdest aus dem Offboarding entferntz"Has sido eliminado del offboardingu(Vous avez été retiré de l'offboardingr�r�r�zEmployees not found)rtr�r/rPrQr�rr�r�rr�r�r�r�values_listr
r�rr{)rxrJ�	instancesrBrBrG�delete_employeeSs*���r�z#offboarding.delete_offboardingstagecCs�|j�d�}z(tjj|d�}|r|��t�|td��n
t�	|td��Wtd�SWtd�St
yBt�	|td��Ytd�Sw)z>
    This method  is used to delete the offboarding stage
    �idsr�z
Stage deletedzStage not foundr�)rtr�r2rPrQr�rr�r�r�r�r	)rxr�r�rBrBrG�delete_stageps���r�zoffboarding.change_offboardingc	Cs�|j�d�}|jd}tjj|d�}tjj|d�}|D]	}||_|��qi}t	|j
d�|t|j
j�<t
j|jjtjj|jddd�d�d	d
ddd
td�dd�	ti|j
g�}|D]}t|dd|d�qXt|d|d|td�t����d��S)zB
    This method is used to update the stages of the employee
    rJr=r�rCrlr�Tr�z"Offboarding stage has been changedu2تم تغيير مرحلة إنهاء الخدمةu%Die Offboarding-Stufe wurde geändertz&Se ha cambiado la etapa de offboardingu'L'étape d'offboarding a été changéer�r�r�r8r9�'offboarding/stage/offboarding_body.htmlrzstage changed successfully.�r8rq�response_messagers)rtr�r/rPrQr2rUr=r�r+r�rSr7rr�r�r�rr�r
rdrurr�rrsrw)	rxrJr=r:r]rFrqrZryrBrBrG�change_stage�sH

���

��r�z offboarding.view_offboardingnotec
Cs�|jr1|j�d�}|jd}tjj|d�}g}|D]}t�}||_|��|�	|�q|j
j|�|}tjj|d�}	t
|dd|	i�S)zE
    This method is used to render all the notes of the employee
    �files�note_idrC� offboarding/note/view_notes.htmlrF)�FILESr�rtr1rPrUr3�
attachmentr�rO�attachments�addr/r)
rxr�r�r��noter��filer��offboarding_employee_idrFrBrBrG�
view_notes�s&	
��r�cCs~|jd}tjj|d�}t�}|jdkr6t|j|j�}||j_	|�
�r6|��t�
|td��td|jd�St|d||d��S)	zI
    This method is used to create note for the offboarding employee
    r�rCrzNote added successfullyzview-offboarding-note�r�r�)r�rF)rtr/rPrUr&r�rr�r~r�r�r�rr�r�rr7r)rxr�rFr�rBrBrG�add_note�s"

��r�z"offboarding.delete_offboardingNote)�permcCsdd}ztjj|d�}|��t�|td��Wt	|�Stjy1t�|td��d}Yt	|�Sw)z<
    This method is used to delete the offboarding note
    �rCz'The note has been successfully deleted.zNote not found.r�)
r1rPrUr�rr�r�r�r�r	)rxr��scriptr�rBrBrG�offboarding_note_delete�s��r�z"offboarding.delete_offboardingnotecCs:d}|j�d�}tjj|d���t�|td��t	|�S)z#
    Used to delete attachment
    r�r�r�zFile deleted successfully)
rtr�r3rPrQr�rr�r�r	)rxr�r�rBrBrG�delete_attachments
r�zoffboarding.add_offboardingtaskcCs�|j�d�}tt|j�d���}tjj|d�}d}|r$tjj|d���}t	||d�|d�}|j
dkrLt	|j|d|id	�}|��rL|�
�t�|td
��t|dd|i�S)
z6
    This method is used to add offboarding tasks
    r=r|)r=NrC)r=�tasks_tor�r)r~r�z
Task Addedzoffboarding/task/form.htmlr�)rtrUrrSr/rPrQr4r�r,r�rr�r�rr�r�r)rxr=r|r:r~r�rBrBrG�add_tasks8��
����r�zoffboarding.change_employeetaskcOs�|jd}|j�d�}|jd}|jd}tjj||d�}|j|d�tj|jj	t
jj|jddd	�d
�ddd
ddtd�dd�	t
jj|d�}i}	t|jd�|	t|jj�<ti|jg�}
|
D]}t|dd|d�q]t|d|
d|	td�d��S)zA
    This method is used to update the assigned tasks status
    r=rJ�task_id�task_status)�employee_id__id__in�task_id__id)�status�#task_id__managers__employee_user_idTr�r�z(Offboarding Task status has been updatedu9تم تحديث حالة مهمة إنهاء الخدمةz5Der Status der Offboarding-Aufgabe wurde aktualisiertz6Se ha actualizado el estado de la tarea de offboardingu8Le statut de la tâche d'offboarding a été mis à jourr�r�r�rCrlr8r9r�rz!Task status changed successfully.)r8rqr�)rtr�r-rPrQ�updaterr�r�r�rr�r
r2rUr+r�rSr7rdrurr�)rx�args�kwargsr=rJr�r��
employee_taskr]rqrZryrBrBrG�update_task_status7sN


�������r�zoffboarding.add_employeetaskcCs�|j�d�}|jd}tjj|d�}tjj|d�}|D]}zt�}||_||_	|�
�WqYq|��jj
}i}t|d�|t|j�<ti|jj
g�}	|	D]}
t|
dd|
d�qNt|d|	d	|td
�t����d��S)z9
    This method is used to assign task to employees
    rJr�r�rCrlr8r9r�rz
Task Assignedr�)rtr�r/rPrQr4rUr-r�r�r�r�r=r�r+rSr7rdrurr�rrsrw)rxrJr�r:�taskrF�
assigned_taskr8rqrZryrBrBrG�task_assignis6

��r�z"offboarding.delete_offboardingtaskcCsV|j�d�}tjj|d�}|r|��t�|td��t
t�St�	|td��t
t�S)z0
    This method is used to delete the task
    �task_idsr�zTask deletedzTask not found)rtr�r4rPrQr�rr�r�r�rr{)rxr��tasksrBrBrG�delete_task�s�r�cCs�tjj|d�}tjj|d�}i}tjj|jjd�}t|jjd�|t	|jjj
�<||tj||d�}|j�d�}|rPt
�|�}t||�\}	}
||d<|	|d<|
|d<t|d	|�S)
z�
    This method is used to get the individual view of the offboarding employees
    parameters:
        emp_id(int): the id of the offboarding employee
    rCr�)r�rl)rFr��choices�offboarding_stagesrq�requests_ids�previous�nextz)offboarding/pipeline/individual_view.html)r/rPrUr-rQr2r=r�r+rSr7�statusesrt�json�loadsrr)rx�emp_idrFr�rqr��context�requests_ids_jsonr��previous_id�next_idrBrBrG�offboarding_individual_view�s.���
r��"offboarding.view_resignationletter�resignation_requestc	CsPddi}t�}tj��}tj��}t|dt||j�d��|ddgi|t	j
d��S)z=
    This method is used to view the resignation request
    r��	requestedz*offboarding/resignation/requests_view.htmlr@�	Requested)�letters�frrrY�	gp_fields)r!r5rPrLr.rrrtrUr"�fields)rx�defatul_filter�filter_instancer�rYrBrBrG�request_view�s

��rcCsbtjj|d�}d|i}|j�d�}|r+t�|�}t||�\}}||d<||d<||d<t|d|�S)NrC�letterr�r�r�z0offboarding/resignation/request_single_view.html)r5rPrUrtr�r�rr)rxr7rr�r�r�r�r�rBrBrG�request_single_view�s�
�rc
Csp|j�d�r
t|j�j}ntjj|jd�}|j�d�}t	|j�
��}d}|j�d�dkr.d}|j�d�r?t||d�}|�d�|d	krv|d
urvt
|||j�d�d�}dd
�|D�}g}|D]}|jD]}|�|j�qbq]t�t|��}	d}nt||j�d��}t�dd
�|jD��}	|j�d�r�|�d�|j�d�r�|j�d��d�r�dnd}
t|||||j�
�|
|	|d��S)z9
    This method is used to search/filter the letter
    r�)r��fieldz*offboarding/resignation/request_cards.html�viewr<z)offboarding/resignation/request_list.htmlrr�Nr@cSsg|]}|d�qS)r<rB)rE�entryrBrBrGrHsz.search_resignation_request.<locals>.<listcomp>z%offboarding/resignation/group_by.htmlcSrArBrC)rEr~rBrBrGrHr��HTTP_REFERER�employee-profile/FT)r�rr�pd�
paginationr�r)r��has_permr!rtrMr5rPrQrUrrvr�poprTrVrOr7r��dumpsr<r�META�endswithr)rxr�r�	data_dict�template�list_values�id_list�valuer~r�r	rBrBrG�search_resignation_request�sX�

�

�����rcCs\|j�d�}tjj|d���t�|td��|j	�
d�r*|j	�
d��d�r*td�Stt
�S)zC
    This method is used to delete resignation letter instance
    �
letter_idsr�zResignation letter deletedrrz/employee/employee-profile/)rtr�r5rPrQr�rr�r�r
rUrrr)rxr�rBrBrG�delete_resignation_request*s�rcCs�tt|j�d���}d}|rtjj|d�}t|d�}|jdkr:t|j|d�}|�	�r:|�
�t�|t
d��td�St|dd	|i�S)
zK
    This method is used to render form to create resignation requests
    r|NrCr}rzResignation letter savedr�z!offboarding/resignation/form.htmlr�)rrSrtrUr5rPr*r�rr�r�rr�r�r	r)rxr|r~r�rBrBrG�create_resignation_request;s

rz$offboarding.change_resignationlettercCsx|j�d�}|jd}|j�d�}t�d�rtddd�j��nd}|r_tjj|d�}|j�d	�}|j�d
�}|r@t	�
|d���}t	��}|rOt	�
|d���}nd}|r[|t
|jd�}|s_|}tjj|d
�}	|dvr�|	D]K}
||
_|
��|dkr�|
�|||�t�|d|
�����tj|jj|
jjd|
����d|
���d�d|
����d|
����d|
����ddd�	qltt�S)zH
    This method is used to update the status of resignation letter
    rr�r��payroll�payrollgeneralsetting��	app_label�modelNrC�notice_period_startsr��%Y-%m-%dr�r�)�approved�rejectedrzResignation request has been uتم u طلب الاستقالةuDer Rücktrittsantrag wurde z!La solicitud de renuncia ha sido u!La demande de démission a été �#r�r�)rtr�rUr�is_installedrrPr�r.r�strptimerwrsr�
notice_periodr5rQr�r��to_offboarding_employeerr��get_status_displayrr�r�r�r�r�rr)rxr�r�r��default_notice_endr8rr�rsr�rrBrBrG�
update_statusPst
�����������r(z)offboarding.add_offboardinggeneralsettingcCsptj��}|r	|nt�}d|j��v|_|��|jrdnd}t�|t	d��
|��|j�d�r4t
d�Stt�S)z3
    Enable disable resignation letter feature
    r��enabled�disabledz5Resignation Request setting has been {} successfully.�HTTP_HX_REQUESTaK
                            <span hx-trigger="load"
                            hx-get="/"
                            hx-swap="outerHTML"
                            hx-select="#offboardingGenericNav"
                            hx-target="#offboardingGenericNav">
                            </span>
                            )r0rPr�rt�keysr�r�rr�r��formatr
rUr	rr)rx�resignation_request_feature�message_textrBrBrG�enable_resignation_request�s&
������
r0cCs�|jd}t�d�r1tddd�}|jj|dd���r&|j�d�j|d���n	|jj|dd���}nd	}t|�d
dt	t
�����d�}|rJ|j
|d
<t|�S)zF
    This method is used to get initial details for notice period
    r�r�contractr�active)�employee_id__id�contract_statusz-id)r3Nr��month)r$�unitrr$)rtrr"rrPrQr�rNrrSrrsrw�notice_period_in_daysr
)rxr��Contract�employee_contract�responserBrBrG�get_notice_period�s2

��
���
�
r;cCsF|j�d�}t�|d���}t|�d}|t|d�}d|i}t|�S)zd
    Calculates and returns the end date of the notice period based on the provided start date.
    �
start_daterr�r�r�)rtrUrr#rwrrr
)rxr<r$r�r:rBrBrG�get_notice_period_end_date�s�r=)N)ir�rr�urllib.parser�django.appsr�django.contribr�django.contrib.auth.modelsr�django.core.paginatorr�django.httpr	r
�django.shortcutsrr�django.urlsr
�django.utils.translationrr��base.context_processorsr�base.methodsrrrr�
base.viewsr�employee.modelsr�horilla.decoratorsrrrr�horilla.group_byrrT�horilla.methodsr�notifications.signalsr�offboarding.decoratorsrrrr �offboarding.filtersr!r"r#r$r%�offboarding.formsr&r'r(r)r*r+r,�offboarding.modelsr-r.r/r0r1r2r3r4r5rdrjrzr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr(r0r;r=rBrBrBrG�<module>s�$,	
5	�&�(
$+1�
%�."!9@#!

Youez - 2016 - github.com/yon3zu
LinuXploit