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/base/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/base/__pycache__/forms.cpython-310.pyc
o

hͦh�O�@sdZddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZmZddlmZmZmZddlmZdd
lmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z3ddl1m4Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYddlZm[Z[ddl\m]Z]ddl^m_Z_ddl`maZaddlbmcZcddldmeZedd lfmgZgdd!lhmiZidd"ljmkZkd#d$�Zld%e5d&�fd'e5d(�fd)e5d*�fgZmd+d,�Znd-d.�ZoGd/d0�d0ejp�ZpGd1d2�d2ejq�ZqGd3d4�d4ep�ZrGd5d6�d6eq�ZsGd7d8�d8eq�ZtGd9d:�d:ep�ZuGd;d<�d<ep�ZvGd=d>�d>ep�ZwGd?d@�d@ep�ZxGdAdB�dBep�ZyGdCdD�dDep�ZzGdEdF�dFep�Z{GdGdH�dHep�Z|GdIdJ�dJejp�Z}GdKdL�dLep�Z~GdMdN�dNep�ZGdOdP�dPep�Z�GdQdR�dRep�Z�GdSdT�dTep�Z�GdUdV�dVejp�Z�GdWdX�dXep�Z�GdYdZ�dZep�Z�Gd[d\�d\ep�Z�Gd]d^�d^ep�Z�Gd_d`�d`ejq�Z�Gdadb�dbe�Z�gdc�Z�Gddde�deejq�Z�Gdfdg�dgejq�Z�Gdhdi�diejq�Z�Gdjdk�dkejq�Z�Gdldm�dmep�Z�Gdndo�doep�Z�Gdpdq�dqep�Z�Gdrds�dsep�Z�Gdtdu�duep�Z�Gdvdw�dwejq�Z�Gdxdy�dyep�Z�Gdzd{�d{ep�Z�Gd|d}�d}ep�Z�Gd~d�dej��Z�Gd�d��d�ej��Z]Gd�d��d�ep�Z�Gd�d��d�ep�Z�Gd�d��d�ep�Z�Gd�d��d�ejp�Z�e�Z�Gd�d��d�ejq�Z�d�d��Z�Gd�d��d�ejp�Z�Gd�d��d�ep�Z�Gd�d��d�ep�Z�Gd�d��d�ep�Z�Gd�d��d�ejq�Z�Gd�d��d�ep�Z�Gd�d��d�ep�Z�dS)�zA
forms.py

This module is used to register forms for base module
�N)�date�	timedelta)�Any)�forms)�apps)�settings)�messages)�get_user_model)�SetPasswordForm�_unicode_ci_compare)�Group�
Permission�User)�default_token_generator)�get_current_site)�ValidationError)�EmailMultiAlternatives)�validate_ipv46_address)�	DateInput�HiddenInput�	TextInput)�loader��render_to_string)�force_bytes)�urlsafe_base64_encode)�gettext)�gettext_lazy)�reload_queryset)!�Announcement�AnnouncementComment�AnnouncementExpire�
Attachment�AttendanceAllowedIP�BaserequestFile�Company�
CompanyLeaves�
Department�DriverViewed�DynamicEmailConfiguration�DynamicPagination�
EmployeeShift�EmployeeShiftDay�EmployeeShiftSchedule�EmployeeType�Holidays�HorillaMailTemplate�JobPosition�JobRole�MultipleApprovalCondition�PenaltyAccounts�
RotatingShift�RotatingShiftAssign�RotatingWorkType�RotatingWorkTypeAssign�ShiftRequest�ShiftRequestComment�Tags�TrackLateComeEarlyOut�WorkType�WorkTypeRequest�WorkTypeRequestComment)�EmployeeFilter)�MultipleFileField)�Employee)�horilla_middlewares)�_thread_locals)�get_horilla_model_class)�AuditTag)�HorillaMultiSelectField)�HorillaMultiSelectWidgetc
Cs�t|�dkrttd���z&|�d�\}}t|�}t|�}tt|��dks*|td�vr0ttd���WdStyE}zttd��|�d}~ww)zM
    this method is used to validate the format of duration like fields.
    �z)Invalid format, it should be HH:MM format�:��<N)�lenr�_�split�int�str�range�
ValueError)�value�hour�minute�error�rX�/var/www/erp/base/forms.py�validate_time_formatTs���rZ�after�After�weekly�Weekend�monthly�MonthlycCs:|��|kr|S||��d}|dkrd}|t|d�S)ap
    Calculates the date of the next occurrence of the target day within the next week.

    Parameters:
        target_day (int): The target day of the week (0-6, where Monday is 0 and Sunday is 6).
        start_date (datetime.date): The starting date.

    Returns:
        datetime.date: The date of the next occurrence of the target day within the next week.
    �r��days)�weekdayr)�
target_day�
start_date�days_until_target_dayrXrXrY�get_next_week_dateksrhcCs
|dkrt�|j|j�d}t|�}t|�}|j|ks|dkrJzt�|j|j|�}W|St	yIt�|j|jdd�}t�|j|j|�}Y|Swt�|j|j�d}|j
|d�tdd�}z	|j
|d�}W|St	y�|j
|jdd�tdd�j
|d�}Y|Sw)ar
    Given a start date and a rotation day (specified as an integer between 1 and 31, or
    the string 'last'),calculates the next rotation date for a monthly rotation schedule.

    If the rotation day has not yet occurred in the current month, the next rotation date
    will be on the rotation day of the current month. If the rotation day has already
    occurred in the current month, the next rotation date will be on the rotation day of
    the next month.

    If 'last' is specified as the rotation day, the next rotation date will be on the
    last day of the current month.

    Parameters:
    - start_date: The start date of the rotation schedule, as a datetime.date object.
    - rotate_every: The rotation day, specified as an integer between 1 and 31, or the
      string 'last'.

    Returns:
    - A datetime.date object representing the next rotation date.
    �last�r��dayrb)�month)�calendar�
monthrange�yearrmrQrPrl�datetimerrS�replacer)rf�rotate_every�last_day�next_change�next_month_startrXrXrY�get_next_monthly_date~s<��
������rwc� eZdZdZ�fdd�Z�ZS)�	ModelFormz=
    Override django model's form to add initial styling
    cs�t�j|i|��t|j�ttjdd�}|j��D]�\}}|j}t	|t
j�r,t�
�|_t	|t
jt
jt
jt
jf�rRd}|jdurGt|j���}|jj�d|d��nWt	|t
jf�r�d|_t	|t
j�swd}|jdurnt|j�}td�j|d�|_|jj�ddi�n(t	|t
j�r�|jj�dt|j�d	d
d��nt	|t
jt
jf�r�|jj�ddi�z
|jj |jd
_WnYz|jj j!|jd_WqYqdS)N�request��oh-input w-100��class�placeholder�---Choose {label}---��labelr~�/oh-select oh-select-2 select2-hidden-accessible��(�r~r�rows�cols�oh-switch__checkbox�employee_id�
company_id)"�super�__init__r�fields�getattrrCrD�items�widget�
isinstancerrr�today�initial�NumberInput�
EmailInputr�	FileInputr�rN�title�attrs�update�Select�empty_label�ModelMultipleChoiceField�format�Textarea�
CheckboxInput�CheckboxSelectMultiple�user�employee_get�get_company)�self�args�kwargsrz�
field_name�fieldr�r���	__class__rXrYr��sh

�
�

�������zModelForm.__init__��__name__�
__module__�__qualname__�__doc__r��
__classcell__rXrXr�rYry��rycrx)�FormzF
    Overrides to add initial styling to the django Form instance
    cst�j|i|��|j��D]y\}}|j}t|tjtjtj	f�r5|j
dur4t|j
�}|jj�
d|d��qt|tjf�r]d}|j
durJ|j
�dd�}td�j|d�|_|jj�
dd	i�qt|tj�rut|j
�}|jj�
d|d
dd��qt|tjtjf�r�|jj�
dd
i�qdS)Nr|r}r{�id� r�r�r~r�r�r�r�r�)r�r�r�r�r�r�rr�r�rr�rNr�r�r�rrr�r�r�r�r�)r�r�r�r�r�r�r�r�rXrYr��sL�

��
�
������z
Form.__init__r�rXrXr�rYr��r�r�csbeZdZdZzejdd�ej��D�dddid�Z	WnYGdd	�d	�Z
d
�fdd�	Z�ZS)�
UserGroupFormz!
    Django user groups form
    cC�g|]}|j|jf�qSrX��codename�name��.0�permrXrXrY�
<listcomp>-�zUserGroupForm.<listcomp>F�required�Please choose a permission.)�choicesr��error_messagesc@seZdZdZeZddgZdS)zUserGroupForm.Meta�3
        Meta class for additional options
        r��permissionsN)r�r�r�r�r�modelr�rXrXrXrY�Meta6sr�TcsVt�jdd�}|jr
|j}|��|jd}tjj|d�}|j�|�|r)|��|S)z)
        ModelForm save override
        F��commitr���codename__in)	r��save�instance�cleaned_datar
�objects�filterr��set)r�r��group�permissions_codenamesr�r�rXrYr�>s
zUserGroupForm.save�T)
r�r�r�r�r�MultipleChoiceFieldr
r��allr�r�r�r�rXrXr�rYr�&s�
�r�csNeZdZdZejej��dd�Z	ej
ej��d�Z�fdd�Z
dd�Z�ZS)	�AssignUserGroupz
    Form to assign groups
    F)�querysetr��r�c� t�j|i|��t|j�dS�N�r�r�rr��r�r�r�r�rXrYr�^�zAssignUserGroup.__init__cCs:|jd}|jd}|j��|D]	}|jj�|�q|S)z:
        Save method to assign group to employees
        �employeer�)r��user_set�clear�employee_user_id�groups�add)r��	employeesr�r�rXrXrYr�bs


zAssignUserGroup.save)r�r�r�r�rr�rBr�r�r��ModelChoiceFieldrr�r�r�r�rXrXr�rYr�Ts
�r�c	s�eZdZdZeej��ede	dddd�dd�Z
zejd	d
�e
j��D�ddid
�ZWnY�fdd�Z�fdd�Zdd�Z�ZS)�AssignPermissionz(
    Forms to assign user permision
    �employee-widget-filter�f�employee_filters.htmlT)�filter_route_name�filter_class�filter_instance_contex_name�filter_template_pathr�rB�r�r�r�cCr�rXr�r�rXrXrYr��r�zAssignPermission.<listcomp>r�r�)r�r�cr�r�r�r�r�rXrYr��r�zAssignPermission.__init__cs,|j�d�}|r|j�dd�t���dS)Nr�)�data�getlist�errors�popr��clean)r��empsr�rXrYr��s

zAssignPermission.cleancCs`tjj|j�d�d�jddd�}|jd}tjj|d�}tjj|d�}|D]}|j	�
|�q%|S)z>
        Save method to assign permission to employee
        r���id__inr�T��flatr�r�)rBr�r�r�r��values_listr�r
r�user_permissionsr�)r��user_idsr��usersr�rXrXrYr��s
��
zAssignPermission.save)r�r�r�r�rGrBr�r�rHr@r�rr�r
r�r�r�r�r�rXrXr�rYr�ns0���
�r�c@s.eZdZdZGdd�d�Zdd�Zdd�ZdS)	�CompanyFormz
    Company model's form
    c@s eZdZdZeZdZgd�ZdS)zCompanyForm.Metar��__all__)�date_format�time_format�	is_activeN)r�r�r�r�r%r�r��excluded_fieldsrXrXrXrYr���
r�cCsHd}|j|krtd��gd�}tj�|j�d��}||vr"td��dS)NiPz"File size should be less than 5MB.)z.jpgz.jpegz.pngz.webpz.svgrjzUnsupported file extension.)�sizer�os�path�splitextr��lower)r��file�max_size�valid_extensions�extrXrXrY�validate_image�s
�zCompanyForm.validate_imagecCs|j�d�}|r
|�|�|S)N�icon)r��getr)r�rrXrXrY�
clean_icon�s
zCompanyForm.clean_iconN)r�r�r�r�r�rrrXrXrXrYr��s
	r�c@�eZdZdZGdd�d�ZdS)�DepartmentFormz!
    Department model's form
    c@�eZdZdZeZdZdgZdS)zDepartmentForm.Metar�r�rN)r�r�r�r�r'r�r��excluderXrXrXrYr���

r�N�r�r�r�r�r�rXrXrXrYr��rc@r)�JobPositionForm�"
    JobPosition model's form
    c@r)zJobPositionForm.Metar�r�rN)r�r�r�r�r1r�r�rrXrXrXrYr��rr�NrrXrXrXrYr�rrcsJeZdZdZeej��d�ZGdd�d�Z	�fdd�Z
�fdd�Z�ZS)	�JobPositionMultiFormrr�c@s2eZdZeZdZddgZdejddd�d�iZ	dS)	zJobPositionMultiForm.Metar��
department_idr�oh-select oh-select2 w-100�height:45px;�r~�style�r�N)
r�r�r�r1r�r�rr�SelectMultiple�widgetsrXrXrXrYr��s���r�cs�t���}|j�d�}|j�d�}tjj||d�}|��r>|j	ddd�}t
jj|d�j	ddd�}tdtd��
d	�|��i��|S)
zd
        Validate that the job position does not already exist in the selected departments.
        r�job_position)�department_id__inr$Tr�r��
departmentz$Job position already exists under {}�, )r�r�r�r�rr1r�r��existsr�r'rrNr��join)r�r��department_idsr$�existing_positions�
existing_deps�	dep_namesr�rXrYr��s$
��
���zJobPositionMultiForm.cleanc
s�|jjsNttd�}|j�d�}|j�d�}g}|D]-}tjj|d�}t	jj
||d���r6t�
|d|���qt	||d�}	|	��|�|	j�qt	jj
|d�St�j|i|��S)zF
        Save the job positions for each selected department.
        rzrr$�r�)rr$z"Job position already exists under r�)r��pkr�rDr�r�rr'r�r1r�r(rrWr��appendr�)
r�r�r�rzr*r$�	positions�dep_id�dep�positionr�rXrYr�s$
��zJobPositionMultiForm.save)
r�r�r�r�rGr'r�r�rr�r�r�r�rXrXr�rYr�s
rcs@eZdZdZ�fdd�ZGdd�d�Zdef�fdd�Z�ZS)	�JobRoleFormz
    JobRole model's form
    csZt�j|i|��|jjs+tj|jdjd�|jd<|jdjj	}d|d<d|d<dSdS)N�job_position_idr�rr~rr )
r�r�r�r/rr�r�r�r�r�)r�r�r�r�r�rXrYr�.s
��zJobRoleForm.__init__c@r)zJobRoleForm.Metar�r�rN)r�r�r�r�r2r�r�rrXrXrXrYr�8rr��returnc		s�|jjsHttd�}tjj|j�d�d�}g}|D](}t	�}||_
|jd|_z|��Wn
t
�|d|���Y|�|j�qt	jj|d�St�j|g|�Ri|��dS)Nrzr6r��job_rolezRole already exists under )r�r/r�rDr1r�r�r�r�r2r6r8r�r�infor0r�)	r�r�r�r�rz�
job_positions�rolesr4�roler�rXrYr�As"

�zJobRoleForm.save)	r�r�r�r�r�r�rr�r�rXrXr�rYr5)s

	r5c@r)�WorkTypeFormz
    WorkType model's form
    c@r)zWorkTypeForm.Metar�r�rN)r�r�r�r�r=r�r�rrXrXrXrYr�Zrr�NrrXrXrXrYr=Urr=c�PeZdZdZGdd�d�Z�fdd�Zdd�Z�fdd	�Zd
�fdd�	Z�Z	S)�RotatingWorkTypeFormz'
    RotatingWorkType model's form
    c@s8eZdZdZeZdZddgZeddid�e	�
�d�Zd	S)
zRotatingWorkTypeForm.Metar�r�r�r�typerr!)rf�additional_dataN)r�r�r�r�r7r�r�rrrrr#rXrXrXrYr�is
�r�c	s�t�j|i|��d}d�fdd�	}�j��D]}|�d�r)|d7}|||dk�q�j�d�}|r7|�d�nd}|rRd	}|D]}|d|��|dk|d
�|d7}q?|�_dS)Nrc�>tjtj��tjd|d|��d�d�|td�|d��j|<dS)N�oh-select oh-select-2 mb-3�id_�r~r�r�r!z---Choose Work Type---�r�r�r�r�r�)rr�r=r�r�r�rNr�)�
work_type_keyr�r��r�rXrY�create_work_type_fieldz����z=RotatingWorkTypeForm.__init__.<locals>.create_work_type_field�	work_typerjr�rA�additional_work_typesrK�r�r�)r�r�r��keys�
startswithr�r�work_type_counts)	r�r�r�rPrI�keyrArL�work_type_idr�rHrYr�vs*
���

zRotatingWorkTypeForm.__init__cO�d|i}td|�S)N�formz9base/rotating_work_type/htmx/rotating_work_type_as_p.htmlr�r�r�r��contextrXrXrY�as_p���zRotatingWorkTypeForm.as_pc�t���}g}t|jj���}|j��D]\}}|�d�|vr+|�d�r+|r+|�	|�q|rBd|vs8|ddur<i|d<||dd<|S)N�_idrKrArL�
r�r��listr��__dict__rNr�r�rOr0)r�r�rL�model_fieldsrQrTr�rXrYr��s(
��
���zRotatingWorkTypeForm.cleanTc�`t�jdd�}|j�d�r!|jduri|_|jd�d�|jd<nd|_|r.|��|��|S)NFr�rArL�r�r�r�rrA�save_m2m�r�r�r�r�rXrYr���
�
�zRotatingWorkTypeForm.saver��
r�r�r�r�r�r�rWr�r�r�rXrXr�rYr?ds
(r?cs�eZdZdZeejjdd�ede	ddd�e
d�d	�Zej
ed
e
d�d�Zejd
e
d�d�Zejejjeje
d�d�ZGdd�d�Z�fdd�Zdd�Z�fdd�Zddd�Z�ZS)�RotatingWorkTypeAssignForm�-
    RotatingWorkTypeAssign model's form
    F��employee_work_info__isnullr�r�r��r�r�r�r��	Employeesr��daily�Based on�r�r�r���Rotate after day�r�r��
Start date�r�r�r�c@sNeZdZdZeZdZgd�Zeddid�e	�d�Z
ed�ed	�ed
�d�ZdS)
zRotatingWorkTypeAssignForm.Metar�r���next_change_date�current_work_type�next_work_typerrAr@rr!)rfr�	Is Active�Rotate every weekend�Rotate every)r�rotate_every_weekendrsN)
r�r�r�r�r8r�r�rrrr#�_trans�labelsrXrXrXrYr��s�
�r�cs�t�j|i|��t|j�|j��D]
\}}|jr d|j|_q|jdjj�	dddd��|jdjj�	dddd��|jdjj�	d	d
d��|jdjj�	dd
d��t
jd	dd
d�d�|jd_|jdjj�	ddi�|jdjj�	ddi�dS)N� *rz�w-100�ddisplay:none; height:50px; border-radius:0;border:1px                     solid hsl(213deg,22%,84%);T�r~r zdata-hiddenrs�rotate_after_day�w-100 oh-input� height:50px; border-radius:0;r�based_on�C height:50px; border-radius:0;border:1px solid hsl(213deg,22%,84%);r�r~r@r r!rf�rotating_work_type_idr~�oh-select oh-select-2r��r�r�rr�r�r��label_suffixr�r�r�rr�r�r�r�r�r�r�rXrYr���T
���������������z#RotatingWorkTypeAssignForm.__init__cC�$|j�d�}|r|dSttd��S)Nr�r�This field is required�r�rrrN�r��employee_idsrXrXrY�clean_employee_id2sz,RotatingWorkTypeAssignForm.clean_employee_idc�|t���tjj|j�d�d���|j_	|j
�dd�|jj	dur)tdt
d�i��t���t���}d|j
vr<|j
d=|S�Nr�r.r�r��r�r�rBr�r�r�r�firstr�r�r�r�rrN�r�r�r�rXrYr�9�

��


z RotatingWorkTypeAssignForm.cleanNcCsp|j�d�}tjj|jdd�}|jd}gd�}|�|���}|D]�}tjj	|d��
�}	t�}
||
_|	|
_
|jd|
_|jd|
_|jd|
_|j�d�|
_|jd	|
_|jd|
_|jd|
_|	jj|
_|j|
_d
|
jd<|jd}|jd}|dkr�t||�}
|
|
_n+|d
kr�|jd	}|jd}t||�}
|
|
_n|dkr�|
jtjt|j�d��d�|
_|
��q"dS)Nr�r�r.rz��monday�tuesday�	wednesday�thursday�friday�saturday�sundayr�rfr�rsrj�next_shift_indexr]r_r[rb) r�r�r7r�rr��indexr	rBr�r�r8r�r�r�rfrtr�rsrz�employee_work_inforRru�
work_type1rvrArhrwrqrrPr�)r�r��managerr��rotating_work_type�day_name�	day_namesrer�r��rotating_work_type_assignr�rf�	next_datersrXrXrYr�HsX�
	���






��
�zRotatingWorkTypeAssignForm.save)FN�r�r�r�r�rGrBr�r�rHr@r{r�r�ChoiceField�BASED_ONr��IntegerFieldr��	DateFieldrqrr�rrfr�r�r�r�r�r�rXrXr�rYre�s0��

��5rec�NeZdZdZejeded�d�ZGdd�d�Z	�fdd�Z
�fd	d
�Z�ZS)� RotatingWorkTypeAssignUpdateFormrfrkrlrmc@�\eZdZdZeZdZgd�Zdeddid�iZ	e
d�e
d	�e
d
�e
d�e
d�e
d
�d�ZdS)z%RotatingWorkTypeAssignUpdateForm.Metar�r�rsrfr@rr!rqrorxryrlrw�rfr�rzrsr�rN)r�r�r�r�r8r�r�rrr#r{r|rXrXrXrYr����
�r�cs�t�j|i|��t|j�|j��D]
\}}|jr d|j|_q|jdjj�	dddd��|jdjj�	dddd��|jd	jj�	d
dd��|jd
jj�	ddd��t
jd
ddd�d�|jd_|jdjj�	ddi�|jdjj�	ddi�dS)Nr}rzr~zcdisplay:none; height:50px; border-radius:0;border:1px                    solid hsl(213deg,22%,84%);Tr�rsrr�r�r�rr�zX height:50px; border-radius:0; border:1px solid                     hsl(213deg,22%,84%);rr�r!rfr�r~r�r�r�r�r�rXrYr��sT
���������������z)RotatingWorkTypeAssignUpdateForm.__init__c
�|jd}gd�}|�|���}|jd}|jj}|dkr't||�}||j_n,|dkr=|jj}	|jj}t||	�}||j_n|dkrS|jjt	j
t|j�
d��d�|j_t���S�	Nrzr�r�r]r_r[r�rb�r�r�r	r�rfrhrtrsrwrqrrPr�rr�r��
r�r�r�r�r�rer�rfr�rsr�rXrYr���&
	




��
z%RotatingWorkTypeAssignUpdateForm.save�
r�r�r�r�rr�r�r{r�r�r�r�r�rXrXr�rYr��s
�6r�c@r)�EmployeeTypeFormz
    EmployeeType form
    c@r)zEmployeeTypeForm.Metar�r�rN)r�r�r�r�r.r�r�rrXrXrXrYr�rr�NrrXrXrXrYr��rr�c�.eZdZdZGdd�d�Z�fdd�Z�ZS)�EmployeeShiftFormz
    EmployeeShift Form
    c@s eZdZdZeZdZddgZdS)zEmployeeShiftForm.Metar�r�rcrN)r�r�r�r�r+r�r�rrXrXrXrYr�rr�cs.|jd}t|�|jd}t|�t���S)N�	full_time�weekly_full_time)r�rZr�r�)r�r�r�rXrYr�s



zEmployeeShiftForm.clean)r�r�r�r�r�r�r�rXrXr�rYr�
s	r�csBeZdZdZGdd�d�Z�fdd�Zdd�Z�fdd	�Z�ZS)
�EmployeeShiftScheduleUpdateForm�,
    EmployeeShiftSchedule model's form
    c@sBeZdZdZeZdZddgZej	ddid�ej	ddid�d�Z
d	S)
z$EmployeeShiftScheduleUpdateForm.Metar�r�r�is_night_shiftr@�timer!��
start_time�end_timeN)r�r�r�r�r-r�r�rr�	TimeInputr#rXrXrXrYr�%s
�r�cs�t�j|i|��|�d�}|rB|jr|j�d�nd|jd_|jr(|j�d�nd|jd_t�	d�rB|j
r<|j
�d�nd|jd_t�	d�sW|j�dd�|j�dd�dStj
dd	d
�d�|jd_|jdjj�dd
i�dS)Nr��%H:%Mr�r��
attendance�auto_punch_out_time�is_auto_punch_out_enabledr��oh-input w-100 form-control�r@r~r!�onchange�toggleDivVisibility(this))r�r�rr��strftimer�r�r�r�is_installedr�r�rr�r�r�r�)r�r�r�r�r�rXrYr�2s*

�
�
�
�
��z(EmployeeShiftScheduleUpdateForm.__init__cC�d|i}td|�}|S�zS
        Render the form fields as HTML table rows with Bootstrap styling.
        rTzhorilla_form.htmlr�r�rV�
table_htmlrXrXrYrWO�
z$EmployeeShiftScheduleUpdateForm.as_pcsft���}t�d�r1|�d�}|�d�}|�d�}|r1|s%tdtd�i��||kr1tdtd�i��|S�Nr�r�r�r�zIAutomatic punch out time is required when automatic punch out is enabled.z=Automatic punch out time cannot be earlier than the end time.)r�r�rr�rrrN�r�r��auto_punch_out_enabledr�r�r�rXrYr�Xs*




������z%EmployeeShiftScheduleUpdateForm.clean)	r�r�r�r�r�r�rWr�r�rXrXr�rYr� s
	r�csjeZdZdZejej��d�Z	Gdd�d�Z
�fdd�Zdd�Z�fd	d
�Z
d�fdd
�	Zdd�Z�ZS)�EmployeeShiftScheduleFormr�r�c@s>eZdZdZeZdZddgZeddid�eddid�d�Z	d	S)
zEmployeeShiftScheduleForm.Metar�r�r�rr@r�r!r�N)
r�r�r�r�r-r�r�rrr#rXrXrXrYr�}s
�r�cs|�d�}r*|j�d�|j�d�d�}t�d�r&|jr"|j�d�nd|d<||d<t�j|i|��|j	dj
j�dt
t���i�|j	d	j
j�dt
t���i�t�d�sh|j	�dd�|j	�d
d�dStjddd
�d�|j	d_
|j	d
j
j�ddi�dS)Nr�r�r�r�r�r�rlr��shift_idr�r�r�r�r!r�r�)rr�r�r�rr�r�r�r�r�r�r�r�rQ�uuid�uuid4r�rr�)r�r�r�r�r�r�rXrYr��s,

�
��  
��z"EmployeeShiftScheduleForm.__init__cCr�r�rr�rXrXrYrW�r�zEmployeeShiftScheduleForm.as_pcsrt���}t�d�r7|jd}|jd}|jd}|r%|s%tdtd�i��|r7|r7|r7||kr7tdtd�i��|Sr�)r�r�rr�r�rrNr�r�rXrYr��s,




������zEmployeeShiftScheduleForm.cleanTcsxt�jdd�}|j�d�D]&}t|�t|jj�kr3|j��}|�dt	|�i�t
|�jdd�}|��q
|r:|��|S)NFr�rl)r�r�r�r�rPrlr��copyr�rQr�)r�r�r�rl�	data_copy�shift_scheduler�rXrYr��s
��zEmployeeShiftScheduleForm.savecCsp|jd}|D] }tjj||jdd���}|dur'ttd�jt|j	�d���q|��dur4ttd���|��S)z)
        Validation to day field
        rlr�)rlr�Nz)Shift schedule is already exist for {day}rkzEmployee not chosen)
r�r-r�r�r�r�rrNr�rl)r�rcrlr�rXrXrY�	clean_day�s"

�����z#EmployeeShiftScheduleForm.clean_dayr�)r�r�r�r�rr�r,r�r�rlr�r�rWr�r�r�r�rXrXr�rYr�ts�
	r�cr>)�RotatingShiftFormz$
    RotatingShift model's form
    c@s,eZdZdZeZdZddgZde�	�iZ
dS)zRotatingShiftForm.Metar�r�r�rrAN)r�r�r�r�r5r�r�rrrr#rXrXrXrYr��sr�c	s�t�j|i|��d}d�fdd�	}�j��D]}|�d�r.�j|r.|d7}|||dk�q�j�d�}|r<|�d�nd}|rYd	}|D]}|rX|d|��|dk|d
�|d7}qD|�_dS)NrcrB)NrCrDrEr!z---Choose Shift---rF)rr�r+r�r�r�rNr�)�	shift_keyr�r�rHrXrY�create_shift_fieldrJz6RotatingShiftForm.__init__.<locals>.create_shift_field�shiftrjr�rA�additional_shiftsrKrMr�)r�r�r�rNrOr�r�shift_counts)	r�r�r�r�r�rQrAr�r�r�rHrYr��s*����
zRotatingShiftForm.__init__cOrS)NrTz1base/rotating_shift/htmx/rotating_shift_as_p.htmlrrUrXrXrYrW&rXzRotatingShiftForm.as_pcrY)NrZr�rAr�r[)r�r�r�r^rQrTr�rXrYr�,s

�zRotatingShiftForm.cleanTcr_)NFr�rAr�r`rbr�rXrYr�?rczRotatingShiftForm.saver�rdrXrXr�rYr��s
(r�cs�eZdZdZeejjdd�ede	ddd�e
d�d	�Zej
ed
e
d�d�Zejd
e
d�d�Zejejjeje
d�d�ZGdd�d�Z�fdd�Zdd�Z�fdd�Z	ddd�Z�ZS)�RotatingShiftAssignForm�*
    RotatingShiftAssign model's form
    Frgr�r�r�rirjr�rkrlrmrnrorprqrrc@sVeZdZdZeZdZgd�Zdeddid�iZ	e
d�ed	�e
d
�e
d�e
d�d
�ZdS)zRotatingShiftAssignForm.Metar�r��rt�
current_shift�
next_shiftrrArfr@rr!zRotating Shiftrqrwrxry)�rotating_shift_idrfrrzrsN)
r�r�r�r�r6r�r�rrr#r{rNr|rXrXrXrYr�gs�
�r�c�t�j|i|��t|j�|j��D]
\}}|jr d|j|_q|jdjj�	dddd��|jdjj�	dddd��|jdjj�	d	d
d��|jdjj�	d
dd��t
jd	dd
d�d�|jd_|jdjj�	ddi�|jdjj�	ddi�dS)Nr}rz�w-100 rTr�rsr�r�r�rr�r~r�rr�r!rfr�r~r�r�r�r�r�rXrYr��r�z RotatingShiftAssignForm.__init__cCr�)z1
        Validation to employee_id field
        r�rr�r�r�rXrXrYr��sz)RotatingShiftAssignForm.clean_employee_idcr�r�r�r�r�rXrYr��r�zRotatingShiftAssignForm.cleancCsp|j�d�}tjj|jdd�}|jd}gd�}|�|���}|D]�}tjj	|d��
�}t�}	||	_||	_
|jd|	_|jd|	_|jd|	_|j�d�|	_|jd	|	_|jd|	_|jd|	_|jj|	_|j|	_d
|	jd<|jd}
|jd}|
dkr�t||�}||	_n+|
d
kr�|jd	}
|jd}t||
�}||	_n|
dkr�|	jtjt|j�d��d�|	_|	��q"dS)Nr�r�r.rzr�r�rfr�rsrjr�r]r_r[rb) r�r�r5r�rr�r�r	rBr�r�r6r�r�r�rfrtr�rsrzr�r�r��shift1r�rArhrwrqrrPr�)r�r�r��rotating_shiftr�r�rer�r��rotating_shift_assignr�rfr�rsrXrXrYr��sN
	�







��
�zRotatingShiftAssignForm.save)Fr�rXrXr�rYr�Ps2��

��5
�r�cr�)�RotatingShiftAssignUpdateFormr�rkrlrmc@r�)z"RotatingShiftAssignUpdateForm.Metar�r�r�rfr@rr!rqrorxryrlrwr�N)r�r�r�r�r6r�r�rrr#r{r|rXrXrXrYr�
r�r�cr�)Nr}rzr�zedisplay:none; height:50px; border-radius:0; border:1px                     solid hsl(213deg,22%,84%);Tr�rsr�r�r�rr�r~zD height:50px; border-radius:0; border:1px solid hsl(213deg,22%,84%);rr�r!rfr�r~r�r�r�r�r�rXrYr�'r�z&RotatingShiftAssignUpdateForm.__init__c
r�r�r�r�r�rXrYr�\r�z"RotatingShiftAssignUpdateForm.saver�rXrXr�rYr�s
�5r�c�>eZdZdZGdd�d�Zdd�Zd
def�fdd	�
Z�ZS)�ShiftRequestForm�#
    ShiftRequest model's form
    c@sVeZdZdZeZdZgd�Zeddid�eddid�d�Z	e
d�e
d	�e
d
�d�ZdS)
zShiftRequestForm.Metar�r�)�
reallocate_to�approved�canceled�reallocate_approved�reallocate_canceled�previous_shift_idr�
shift_changedr@rr!��requested_date�requested_till�Description�Requested Date�Requested Till��descriptionr�rN�r�r�r�r�r9r�r�rrr#r{r|rXrXrXrYr��s�
�r�cCr�r�rr�rXrXrYrW��
zShiftRequestForm.as_p.r�c�B|jjs|jj}t|d�r|jj|j_|jjrd|j_t	��
|�S�Nr�)r�r�r��hasattrr�r�r��is_permanent_shiftrr�r��r�r�r�r�rXrYr��s
zShiftRequestForm.save�.�	r�r�r�r�r�rW�boolr�r�rXrXr�rYr�{s
r�csJeZdZdZGdd�d�Z�fdd�Zdd�Zdd	ef�fd
d�
Z�Z	S)
�ShiftAllocationFormr�c@sTeZdZdZeZdZdZeddid�eddd�d�d	�Z	e
d
�e
d�e
d�d
�ZdS)zShiftAllocationForm.Metar�r�)rr�r�r�r�r�rr�r@rr!�true)r@r�r�rrrrNrrXrXrXrYr��s�
�r�c�2t�j|i|��|jdjj�dddd��dS)Nr�z#id_reallocate_to_parent_div�changez/update-employee-allocation)�	hx-target�
hx-trigger�hx-get�r�r�r�r�r�r�r�r�rXrYr�����zShiftAllocationForm.__init__cCr�r�rr�rXrXrYrW�rzShiftAllocationForm.as_p.r�csF|jjs|jj}t|d�r|jj|j_|jjs|jj|j_t	��
|�Sr	)r�r�r�r
r�r�r�r�contract_end_dater�r�rr�rXrYr��s
�zShiftAllocationForm.saver
)
r�r�r�r�r�r�rWrr�r�rXrXr�rYr�s
rcr�)�WorkTypeRequestFormz&
    WorkTypeRequest model's form
    c@sReZdZdZeZdZdZeddid�eddid�d�Z	e
d�e
d	�e
d
�d�ZdS)
zWorkTypeRequestForm.Metar�r�)r�r��previous_work_type_idr�work_type_changedr@rr!r�rrr)r�rrN)r�r�r�r�r>r�r�rrr#r{r|rXrXrXrYr��s�
�r�cCr�r�rr�rXrXrYrWrzWorkTypeRequestForm.as_p.r�crr	)r�r�r�r
r�rRr�is_permanent_work_typerr�r�rr�rXrYr�s
�zWorkTypeRequestForm.saver
rrXrXr�rYr�s
rcs�eZdZejed�dejded�dd�d�ed�d	�Zejed
�dejded�dd�d�d�Zejed
�dejded�dd�d�d�Z	�fdd�Z
dd�Zdd�Z�fdd�Z
�ZS)�ChangePasswordFormzOld passwordF�new-passwordzEnter Old Password�&oh-input oh-input--password w-100 mb-2��autocompleterr~r!zEnter your old password.�r��stripr��	help_text�New passwordzEnter New Password)r�r$r��New password confirmation�Re-Enter Passwordcs ||_tt|�j|i|��dSr�)r�r�rr�)r�r�r�r�r�rXrYr�CszChangePasswordForm.__init__cCs&|j�d�}|j�|�st�d��|S)N�old_passwordzIncorrect old password.�r�rr��check_passwordrr)r�r)rXrXrY�clean_old_passwordGs
z%ChangePasswordForm.clean_old_passwordcCs&|j�d�}|j�|�rt�d��|S)N�new_passwordz5New password must be different from the old password.r*)r�r-rXrXrY�clean_new_passwordMs�z%ChangePasswordForm.clean_new_passwordcsBt���}|�d�}|�d�}|r|r||krtdtd�i��|S)Nr-�confirm_passwordz.New password and confirm password do not match)r�r�rrrN)r�r�r-r/r�rXrYr�Vs



�zChangePasswordForm.clean)r�r�r�r�	CharFieldrN�
PasswordInputr)r-r/r�r,r.r�r�rXrXr�rYrsH���������	rcs�eZdZdZejed�dejded�dd�d�ed	�d
�Zejed�dejded�dd�d�ed
�d
�Z	d�fdd�	Z
dd�Z�ZS)�ResetPasswordFormz
    ResetPasswordForm
    r&FrzEnter Strong Passwordr r!r!zEnter your new password.r#r'r(z4Enter the same password as before, for verification.Tcs2|��rttdd�}|rt�|td��t���S)NrzzPassword changed successfully)�is_validr�rDr�successrNr�r�)r�r�rzr�rXrYr��s

zResetPasswordForm.savecCs2|j�d�}|j�d�}||kr|St�td���)z>
        validation method for confirm password field
        �passwordr/zPassword must be same.)r�rrrrN)r�r5r/rXrXrY�clean_confirm_password�s
z(ResetPasswordForm.clean_confirm_passwordr�)
r�r�r�r�rr0rNr1�
new_password1�
new_password2r�r6r�rXrXr�rYr2bs4������
r2)r�rr�r�r�r�
created_at�
created_by�modified_byrA�horilla_historyrAc@�:eZdZej��Zdd�eD�Zej	eej
gd�d�ZdS)�ShiftRequestColumnFormcC�,g|]}t|d�r|jtvr|j|jf�qS��verbose_name�r
r�rrA�r�r�rXrXrYr����

�z!ShiftRequestColumnForm.<listcomp>)r�r�r�rr�r��r�r�r�N)r�r�r�r9�_meta�
get_fieldsr^�
field_choicesrr�r��selected_fieldsrXrXrXrYr>��
�
�r>c@r=)�WorkTypeRequestColumnFormcCr?r@rBrCrXrXrYr��rDz$WorkTypeRequestColumnForm.<listcomp>)r�rRr�rr�r�rEN)r�r�r�r>rFrGr^rHrr�r�rIrXrXrXrYrK�rJrKc@r=)�RotatingShiftAssignExportFormcCr?r@rBrCrXrXrYr��rDz(RotatingShiftAssignExportForm.<listcomp>)r�r�rfrtr�r�r�rEN)r�r�r�r6rFrGr^rHrr�r�rIrXrXrXrYrL�rJrLc@r=)� RotatingWorkTypeAssignExportFormcCr?r@rBrCrXrXrYr��rDz+RotatingWorkTypeAssignExportForm.<listcomp>)r�r�rfrtrurvr�rEN)r�r�r�r8rFrGr^rHrr�r�rIrXrXrXrYrM�rJrMc@�&eZdZdZGdd�d�Zdd�ZdS)�TagsFormz
    Tags form
    c@s4eZdZdZeZdZdeddd�d�iZddgZ	d	S)
z
TagsForm.Metar�r��colorzheight:50px)r@r r!r�rN)
r�r�r�r�r;r�r�rr#rrXrXrXrYr��sr�cOsd|i}td|�}|Sr�r)r�r�r�rVr�rXrXrYrWrz
TagsForm.as_pN�r�r�r�r�r�rWrXrXrXrYrO�s
rOc@r)�AuditTagFormz
    Audit Tags form
    c@�eZdZdZeZdZdS)zAuditTagForm.Metar�r�N)r�r�r�r�rFr�r�rXrXrXrYr��r�NrrXrXrXrYrRrrRc@r)�ShiftRequestCommentFormz$
    Shift request comment form
    c@rS)zShiftRequestCommentForm.Metar���commentN)r�r�r�r�r:r�r�rXrXrXrYr�#rTr�NrrXrXrXrYrUrrUc@r)�WorkTypeRequestCommentFormz'
    WorkType request comment form
    c@rS)zWorkTypeRequestCommentForm.Metar�rVN)r�r�r�r�r?r�r�rXrXrXrYr�1rTr�NrrXrXrXrYrX,rrXc@rN)�DynamicMailConfFormz#
    DynamicEmailConfiguration
    c@�eZdZeZdZdgZdS)zDynamicMailConfForm.Metar�rN)r�r�r�r)r�r�rrXrXrXrYr�?�
r�cCr�r�rr�rXrXrYrWGrzDynamicMailConfForm.as_pNrQrXrXrXrYrY:srYc@seZdZdZejddd�ZdS)�DynamicMailTestFormz
    DynamicEmailTest
    zTo emailT)r�r�N)r�r�r�r�r�
EmailField�to_emailrXrXrXrYr\Prr\c@rN)�MailTemplateFormz
    MailTemplateForm
    c@s*eZdZeZdZdejddd�d�iZdS)zMailTemplateForm.Metar��bodyr{z
display:none;)�data-summernoter r!N)	r�r�r�r0r�r�rr�r#rXrXrXrYr�]s��r�cCszidd�dd�dd�dd�d	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd
�dd d!d"��}|S)#NzReceiver|Full namezinstance.get_full_namezSender|Full namezself.get_full_namezReceiver|Recruitmentzinstance.recruitment_idzSender|Recruitmentzself.recruitment_idzReceiver|Companyzinstance.get_companyzSender|Companyzself.get_companyzReceiver|Job positionzinstance.get_job_positionzSender|Job positionzself.get_job_positionzReceiver|Emailzinstance.get_mailzSender|Emailz
self.get_mailzReceiver|Employee Typezinstance.get_employee_typezSender|Employee Typezself.get_employee_typezReceiver|Work Typezinstance.get_work_typezSender|Work Typezself.get_work_typezCandidate|Full namezCandidate|RecruitmentzCandidate|Companyzinstance.get_emailzinstance.get_interview|safe)zCandidate|Job positionzCandidate|EmailzCandidate|Interview TablerX)r��	mail_datarXrXrY�get_template_languagefsP��������	�
���
������z&MailTemplateForm.get_template_languageN)r�r�r�r�r�rcrXrXrXrYr_Xs	r_c
s�eZdZded�fded�fded�fded�fd	ed
�fded�fd
ed�fded�fgZejgejddid�ed�dd�Zejeejddddd�d�d�Z	Gdd�d�Z
�fdd�Z�ZS) �MultipleApproveConditionForm�equalz
Equal (==)�notequalzNot Equal (!=)rR�Range�ltz
Less Than (<)�gtzGreater Than (>)�lezLess Than or Equal To (<=)�gezGreater Than or Equal To (>=)�	icontains�Containsr~zoh-select oh-select-2 mb-2r!zApproval ManagerT)r�r�r�r�rz#conditionValueDivzcondition-value-fields)r~rrr)r�r�c@rZ)z!MultipleApproveConditionForm.Metar�rN)r�r�r�r3r�r�rrXrXrXrYr��s
�r�csDt�j|i|��dtd�fgdd�tj��D�}||jd_dS)N�reporting_manager_idzReporting ManagercSsg|]	}|jt|�f�qSrX)r/rQ)r�r�rXrXrYr��s�z9MultipleApproveConditionForm.__init__.<locals>.<listcomp>�multi_approval_manager)r�r�rNrBr�r�r�r�)r�r�r�r�r�rXrYr��s
�z%MultipleApproveConditionForm.__init__)
r�r�r�rN�CONDITION_CHOICErr�r�ro�condition_operatorr�r�r�rXrXr�rYrd�s8







�����rdc@r)�DynamicPaginationFormz-
    Form for setting default pagination
    c@seZdZeZdZdZdS)zDynamicPaginationForm.Metar�)�user_idN)r�r�r�r*r�r�rrXrXrXrYr��sr�NrrXrXrXrYrr�rrrc@seZdZdZdS)�MultipleFileInputTN)r�r�r��allow_multiple_selectedrXrXrXrYrt�srtcs*eZdZ�fdd�Zd�fdd�	Z�ZS)rAcs$|�dt��t�j|i|��dS)Nr�)�
setdefaultrtr�r�r�r�rXrYr��szMultipleFileField.__init__NcsHt�j�t|ttf�r��fdd�|D�}n�|��g}|r"|dSdS)Ncsg|]}�|���qSrXrX)r��d�r��single_file_cleanrXrYr��sz+MultipleFileField.clean.<locals>.<listcomp>r)r�r�r�r\�tuple)r�r�r��resultr�rxrYr��s�zMultipleFileField.cleanr�)r�r�r�r�r�r�rXrXr�rYrA�srAcsFeZdZdZGdd�d�Z�fdd�Zddedef�fd	d
�
Z�Z	S)�AnnouncementFormz
    Announcement Form
    c@s>eZdZdZeZdZdgZej	ddid�e
ddid�d	�Zd
S)zAnnouncementForm.Metar�r�rrar{r!r@r)r�expire_dateN)r�r�r�r�rr�r�rrr�rr#rXrXrXrYr��s
�r�cs2t�j|i|��tdd�|jd<d|jd_dS)NzAttachments r��attachmentsF)r�r�rAr�r�r�r�rXrYr��szAnnouncementForm.__init__.r�r7cs�g}g}d}|j�d�r/|j�d�}|d|j_g}|D]}t�}||_|��|�|j�qt	��|�}|r=|j
j|�||fS)Nr~r)�filesr�r��attachementr"r
r�r0r/r��attachementsr�)r�r�r��multiple_attachment_idsr��
file_instancer�r�rXrYr��s zAnnouncementForm.saver
)
r�r�r�r�r�r�rrr�r�rXrXr�rYr|�s

 r|c@r)�AnnouncementCommentFormz#
    Announcement comment form
    c@seZdZdZeZdgZdS)zAnnouncementCommentForm.Metar�rWN)r�r�r�r�r r�r�rXrXrXrYr��s
r�NrrXrXrXrYr��rr�c@r)�AnnouncementExpireFormz"
    Announcement Expire form
    c@rS)zAnnouncementExpireForm.Metar�rbN)r�r�r�r�r!r�r�rXrXrXrYr�
	rTr�NrrXrXrXrYr�	rr�c@r)�
DriverFormz
    DriverForm
    c@seZdZeZdZdS)zDriverForm.Metar�N)r�r�r�r(r�r�rXrXrXrYr�	sr�NrrXrXrXrYr�	rr�c	@sDeZdZe��Z	ddd�Zdd�Zddddeddddf	d	d
�Z	dS)�PassWordResetFormNcCsbt�||�}d�|���}t�||�}t||||g�}	|dur+t�||�}
|	�|
d�|	��dS)zO
        Send a django.core.mail.EmailMultiAlternatives to `to_email`.
        r{Nz	text/html)rrr)�
splitlinesr�attach_alternative�send)r��subject_template_name�email_template_namerV�
from_emailr^�html_email_template_name�subjectr`�
email_message�
html_emailrXrXrY�	send_mail#	szPassWordResetForm.send_mailcs:t���tjjdid��ddi��}��fdd�|D�S)a
        Given an email, return matching user(s) who should receive a reset.

        This allows subclasses to more easily customize the default policies
        that prevent inactive users and users with unusable passwords from
        resetting their password.
        z
%s__iexactrTc3s,�|]}|��rt�t|���r|VqdSr�)�has_usable_passwordrr�)r��u��email�email_field_namerXrY�	<genexpr>J	s���
�z.PassWordResetForm.get_users.<locals>.<genexpr>NrX)�	UserModel�get_email_field_name�_default_managerr�)r�r��active_usersrXr�rY�	get_users;	s
���zPassWordResetForm.get_usersz'registration/password_reset_subject.txtz&registration/password_reset_email.htmlFc

Cs�|jd}
tjj|
d�}|j}|j}
d}z|jj}Wnty,}zWYd}~nd}~ww|r1|}
|s>t|�}|j	}|j
}n|}}|
rj|�|�}|
tj
dtt|j��||dd�|	p[i�}|j|||||
|d�dSdS)zf
        Generate a one-use only link for resetting password and send it to the
        user.
        r�)�usernameNzERP Growthnatives�https)r��domain�	site_name�uidr��token�protocol)r�)r�rr�rr�r�r��	Exceptionrr�r��
make_tokenr�	RESET_URLrrr/r�)r��domain_overrider�r��	use_https�token_generatorr�rzr��extra_email_contextr�r�r�r��	work_mail�e�current_siter�r�r�rVrXrXrYr�Q	sN
��
�	�
��zPassWordResetForm.saver�)
r�r�r�rr0r�r�r�rr�rXrXrXrYr� 	s	
��r�cCsTzt�|�WdSty)ztj|dd�WYdSty(t|�d���ww)NF)�strictz, is not a valid IP address or CIDR notation.)�	ipaddress�
ip_addressrS�
ip_networkr)rTrXrXrY�validate_ip_or_cidr�	s���r�csReZdZejejddd�d�ddd�ZGdd	�d	�Zd
d�Zd�fd
d�	Z	�Z
S)�AttendanceAllowedIPFormrKzform-control w-100)r�r~r!z(Allowed IP Addresses or Network PrefixeszEEnter multiple IP addresses or network prefixes, separated by commas.)r�r�r%c@�eZdZeZdgZdS)zAttendanceAllowedIPForm.Meta�ip_addressesN�r�r�r�r#r�r�rXrXrXrYr��	�
r�cCsX|j�dd����d�}g}|D]}|���d�}|r)|D]}t|�|�|�qq|S)Nr�r{�
r')r�rr$rOr�r0)r�r��cleaned_ips�ip�ip_addrrXrXrY�clean_ip_addresses�	s�z*AttendanceAllowedIPForm.clean_ip_addressesTcsnt�jdd�}|jr't|j�dg��}t|jd�}t|�|��}||jd<nd|jdi|_|r5|��|S)NFr��allowed_ipsr�)	r�r�r/r�rArr�r\�union)r�r�r��existing_ips�new_ips�
merged_ipsr�rXrYr��	s
�zAttendanceAllowedIPForm.saver�)r�r�r�rr0r�r�r�r�r�r�rXrXr�rYr��	s�r�cs@eZdZejddd�ZGdd�d�Zdd�Z�fdd	�Z�Z	S)
�AttendanceAllowedIPUpdateForm�z
IP Address)�
max_lengthr�c@r�)z"AttendanceAllowedIPUpdateForm.Metar�Nr�rXrXrXrYr��	r�r�cCs&zt|�W|Stytd��w)Nz#Enter a valid IPv4 or IPv6 address.)rr)r�rTrXrXrY�validate_ip_address�	s
��z1AttendanceAllowedIPUpdateForm.validate_ip_addresscs0t���}|j��D]\}}|�|�||<q
|Sr�)r�r�r�r�r�)r�r�r�rTr�rXrYr��	s
z#AttendanceAllowedIPUpdateForm.clean)
r�r�r�rr0r�r�r�r�r�rXrXr�rYr��	s
r�cs*eZdZGdd�d�Z�fdd�Z�ZS)�TrackLateComeEarlyOutFormc@r�)zTrackLateComeEarlyOutForm.Meta�	is_enableN)r�r�r�r<r�r�rXrXrXrYr��	r�r�cr)Nr�z7/attendance/enable-disable-tracking-late-come-early-out�thisr)zhx-postrrrr�r�rXrYr��	rz"TrackLateComeEarlyOutForm.__init__)r�r�r�r�r�r�rXrXr�rYr��	sr�csfeZdZdZejejddid�d�Zejejddid�d�Zdd�Z	Gdd	�d	�Z
�fd
d�Z�ZS)�HolidayFormaW
    Form for creating or updating a holiday.

    This form allows users to create or update holiday data by specifying details such as
    the start date and end date.

    Attributes:
        - start_date: A DateField representing the start date of the holiday.
        - end_date: A DateField representing the end date of the holiday.
    r@rr!)r�cCs8|j�d�}|j�d�}|r|r||krttd���|S)Nrf�end_datez3End date should not be earlier than the start date.r�)r�rfr�rXrXrY�clean_end_date�	s�zHolidayForm.clean_end_datec@s*eZdZdZeZdZdgZded�iZ	dS)zHolidayForm.Metar�r�rr��NameN)
r�r�r�r�r/r�r�rrNr|rXrXrXrYr�
s�r�cs,tt|�j|i|��d|jdjjd<dS)Nr�r")r�r�r�r�r�r�r�r�rXrYr�
szHolidayForm.__init__)
r�r�r�r�rr�rrfr�r�r�r�r�rXrXr�rYr��	s��r�c@s>eZdZdZej��Zdd�eD�Ze	j
ee	jgd�d�ZdS)�HolidaysColumnExportForma}
    Form for selecting columns to export in holiday data.

    This form allows users to select specific columns from the Holidays model
    for export. The available columns are dynamically generated based on the
    model's meta information, excluding specified excluded_fields.

    Attributes:
        - model_fields: A list of fields in the Holidays model.
        - field_choices: A list of field choices for the form, consisting of field names
          and their verbose names, excluding specified excluded_fields.
        - selected_fields: A MultipleChoiceField representing the selected columns
          to be exported.
    cCs0g|]}t|d�r|jtvr|j|j��f�qSr@)r
r�rrA�
capitalizerCrXrXrYr�%
s�
�z#HolidaysColumnExportForm.<listcomp>)r�rfr��	recurringrEN)
r�r�r�r�r/rFrGr^rHrr�r�rIrXrXrXrYr�
s
�
�r�cr�)�CompanyLeaveForma�
    Form for managing company leave data.

    This form allows users to manage company leave data by including all fields from
    the CompanyLeaves model except for is_active.

    Attributes:
        - Meta: Inner class defining metadata options.
            - model: The model associated with the form (CompanyLeaves).
            - fields: A special value indicating all fields should be included in the form.
            - exclude: A list of fields to exclude from the form (is_active).
    c@r)zCompanyLeaveForm.Metar�r�rN)r�r�r�r�r&r�r�rrXrXrXrYr�D
rr�cs$t�j|i|��d|jdj_dS)zJ
        Custom initialization to configure the 'based_on' field.
        z"horilla_widgets/select_option.html�
based_on_weekN)r�r�r�r��option_template_namer�r�rXrYr�M
s�zCompanyLeaveForm.__init__�r�r�r�r�r�r�r�rXrXr�rYr�6
s
	r�cr�)�PenaltyAccountFormz
    PenaltyAccountForm
    c@rZ)zPenaltyAccountForm.Metar�rN)r�r�r�r4r�r�rrXrXrXrYr�\
r[r�csr|�dd�}t�j|i|��t�d�r5|r7tddd�}|j��}|jj	|j
ddd�d�}||jd_dSdSdS)	Nr��leave�	leavetype)�	app_labelr��
leave_type_idTr�r�)
r�r�r�rr�rE�available_leaver�r�r�r�r�r�)r�r�r�r��	LeaveType�available_leaves�assigned_leave_typesr�rXrYr�a
s
��zPenaltyAccountForm.__init__r�rXrXr�rYr�W
sr�)�r�rnrqr�rr�rr�typingr�djangor�django.appsr�django.confr�django.contribr�django.contrib.authr	�django.contrib.auth.formsr
r�django.contrib.auth.modelsrr
r�django.contrib.auth.tokensr�django.contrib.sites.shortcutsr�django.core.exceptionsr�django.core.mailr�django.core.validatorsr�django.formsrrr�django.templater�django.template.loaderr�django.utils.encodingr�django.utils.httpr�django.utils.translationrrNrr{�base.methodsr�base.modelsrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?�employee.filtersr@�employee.formsrA�employee.modelsrB�horillarC�horilla.horilla_middlewaresrD�horilla.methodsrE�horilla_audit.modelsrF�2horilla_widgets.widgets.horilla_multi_select_fieldrG�&horilla_widgets.widgets.select_widgetsrHrZr�rhrwryr�r�r�r�r�rrrr5r=r?rer�r�r�r�r�r�r�r�r�rrrr2rr>rKrLrMrOrRrUrXrYr\r_rdrr�ClearableFileInputrt�	FileFieldr|r�r�r�r�r�r�r�r�r�r�r�r�r�rXrXrXrY�<module>s��#


�:A-.5!G,j6xT{a5w4?1C0(-+
j(/"!

Youez - 2016 - github.com/yon3zu
LinuXploit