
    vg>                        d Z ddl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 ddlmZ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 ddlmZ ddlmZ ddl m!Z! ddl"m#Z#m$Z$m%Z% ddl&m'Z'  G d dejP                        Z( G d de
      Z) G d de(      Z* G d de(      Z+ G d de)      Z	 G d de(      Z, G d d e(      Z- G d! d"e(      Z. G d# d$e(      Z/ G d% d&e(      Z0y)'a  
forms.py

This module contains the form classes used in the application.

Each form represents a specific functionality or data input in the
application. They are responsible for validating
and processing user input data.

Classes:
- YourForm: Represents a form for handling specific data input.

Usage:
from django import forms

class YourForm(forms.Form):
    field_name = forms.CharField()

    def clean_field_name(self):
        # Custom validation logic goes here
        pass
    N)date)Any)forms)UserCreationForm)User)	DateInputValidationErrorrender_to_string)gettext_lazy)reload_queryset)EmployeeFilter)EmployeeEmployeeBankDetails)horilla_middlewares)HorillaMultiSelectField)HorillaMultiSelectWidget)CandidateTaskOnboardingStageOnboardingTask)	Candidatec                   "     e Zd ZdZ fdZ xZS )	ModelFormzC
    Overriding django default model form to apply some styles
    c                 D   t        |   |i | t        t        j                  dd       }t        | j                         | j                  j                         D ]3  \  }}|j                  }t        |t        j                        rt        j                         |_        t        |t        j                        r)|j                  j                  j!                  ddi       nOt        |t        j"                  t        j$                  t        j&                  f      r3|j                  j                  j!                  d|j(                  d       nt        |t        j*                  f      r(|j                  j                  j!                  ddi       nt        |t        j,                        r5|j                  j                  j!                  d|j(                  ddd	       nQt        |t        j.                  t        j0                  f      r'|j                  j                  j!                  dd
i       	 |j2                  j4                  | j                  d   _        	 |j2                  j4                  j6                  | j                  d   _        6 y #  Y ;xY w#  Y DxY w)Nrequestclasszoh-input  w-100oh-input w-100r   placeholder/oh-select oh-select-2 select2-hidden-accessible   (   r   r   rowscolsoh-switch__checkboxemployee_id
company_id)super__init__getattrr   _thread_localsr   fieldsitemswidget
isinstancer   r   r   todayinitialattrsupdateNumberInput
EmailInput	TextInputlabelSelectTextareaCheckboxInputCheckboxSelectMultipleuseremployee_getget_company)selfargskwargsr   _fieldr/   	__class__s          $/var/www/horilla/onboarding/forms.pyr*   zModelForm.__init__2   s   $)&)-<<iN$))+ -	HAu\\F&5??4 $

&5??4""))74E*FG**E,<,<eooN "")).u{{K FU\\O4""))OP FU^^5""))!1',{{ ! "	 ''00 ""))74I*JK5<\\5N5NM*2LL--99 L)1S-	Js   4(J2JJJ__name__
__module____qualname____doc__r*   __classcell__rE   s   @rF   r   r   -   s    1 1    r   c                   "     e Zd ZdZ fdZ xZS )UserCreationFormCustomz<
    Overriding user creation form to apply some styles
    c                    t        |   |i | t        | j                         | j                  j	                         D ]8  \  }}|j
                  }t        |t        j                  t        j                  t        j                  t        j                  f      r3|j
                  j                  j                  d|j                  d       t        |t        j                        r(|j
                  j                  j                  ddi       t        |t        j                  t        j                  t        j                  f      r4|j
                  j                  j                  d|j                  d       =t        |t        j                   f      r>d|j                   d|_        |j
                  j                  j                  ddi       t        |t        j$                        r6|j
                  j                  j                  d|j                  d	d
d       t        |t        j&                  t        j(                  f      s|j
                  j                  j                  ddi       ; y )Nz!oh-input oh-input--password w-100r   r   z oh-input oh-calendar-input w-100r   z
---Choose z---r    r!   r"   r#   r&   )r)   r*   r   r-   r.   r/   r0   r   r5   r6   r7   PasswordInputr3   r4   r8   	DateFieldr9   empty_labelr:   r;   r<   )r@   rA   rB   rC   rD   r/   rE   s         rF   r*   zUserCreationFormCustom.__init__k   s   $)&)$))+ .	LHAu\\F%%$$OO''	 ""))!D',{{ FU__6""))74V*WX**E,<,<eooN "")).u{{K FU\\O4&0S$A!""))OP FU^^5""))!1',{{ ! "	 ''00 ""))74I*JK].	LrN   rG   rM   s   @rF   rP   rP   f   s    1L 1LrN   rP   c                   $    e Zd ZdZ G d d      Zy)OnboardingStageFormz(
    Form for OnboardingStage model
    c                        e Zd ZdZeZdZddgZy)OnboardingStageForm.Metaz3
        Meta class to add additional info
        __all__sequence	is_activeN)rH   rI   rJ   rK   r   modelr-   exclude rN   rF   MetarX      s    	  {+rN   r_   NrH   rI   rJ   rK   r_   r^   rN   rF   rV   rV      s    , ,rN   rV   c                   $    e Zd ZdZ G d d      Zy)OnboardingCandidateFormz"
    Form for Candidate model
    c                   f    e Zd ZdZeZdZdZd eddi      iZ	 e
d       e
d	       e
d
      dZy)OnboardingCandidateForm.Meta8
        Meta class for some additional options
        rY   )stage_idassigned_managerconfirmationhiredreferral	portfoliocanceledr[   resumeschedule_datejob_position_idjoining_datetyper   r3   z	Full NameEmailMobile)nameemailmobileN)rH   rI   rJ   rK   r   r\   r-   r]   r   widgetsrC   labelsr^   rN   rF   r_   rd      sP    	 
 IVV,<=
 kNwZk
rN   r_   Nr`   r^   rN   rF   rb   rb      s    
 
rN   rb   c                   $    e Zd ZdZ G d d      Zy)r   z
    Form for User model
    c                       e Zd ZdZeZddgZy)UserCreationForm.Meta;
        Meta class to add some additional options
        	password1	password2N)rH   rI   rJ   rK   r   r\   r-   r^   rN   rF   r_   r|      s    	 {+rN   r_   Nr`   r^   rN   rF   r   r      s    , ,rN   r   c                   B    e Zd ZdZ ej
                  ej                  j                         d      Z	 ej                         Z ej                   ed            Z ej
                  ej                  j                               Z G d d      Z fd	Z fd
Z xZS )OnboardingViewTaskFormz'
    Form for OnboardingTask model
    F)querysetrequiredz
Task title)r8   )r   c                        e Zd ZdZeZdZg dZy)OnboardingViewTaskForm.Metare   rY   )statuscandidate_idonboarding_task_idr[   N)rH   rI   rJ   rK   r   r\   r-   r]   r^   rN   rF   r_   r      s    	 OrN   r_   c                    | j                   j                         D ]  \  }}t        |t              s| j                  j                  |d        t        | j                  j                  |            dk  rt        j                  |di      t        | 1         }| j                   |   j                  j                  | j                  j                  |            }|||<    t        | 1         }|S )N   zThif field is requiredid__in)r-   r.   r0   r   errorspoplendatagetlistr   r	   r)   cleanr   filter)r@   
field_namefield_instancecleaned_dataemployee_datarE   s        rF   r   zOnboardingViewTaskForm.clean   s    *.++*;*;*= 		9&J.*AB
D1tyy((459//=U0VWW$w} $J 7 @ @ G G99,,Z8 !H ! ,9Z(		9 w}rN   c                    t        |   |i | t        t        j                  j                         t        dt        ddd| j                        d      | j                  d<   t        | j                         | j                  j                  d	      }|rt|j                  j                         j                  d
d      }t        j                  j!                  |      }|| j                  d   _        || j                  d   _        y y )Nemployee-widget-filterfemployee_filters.htmlTfilter_route_namefilter_classfilter_instance_contex_namefilter_template_pathr   instanceTask Managersr   r/   r8   managersrf   r   flatr   
candidates)r)   r*   r   r   objectsallr   r   r   r-   r   r2   get	candidatevalues_listr   r   r   )r@   rA   rB   stagecandidate_idscand_querysetrE   s         rF   r*   zOnboardingViewTaskForm.__init__  s    $)&)"9%%))++":+,/%< "#
J 	$  ,!OO//1==nSW=XM%--44M4JM1>DKK%.0=DKK%- rN   )rH   rI   rJ   rK   r   ModelMultipleChoiceFieldr   r   r   r   HiddenInputrf   	CharFieldrC   
task_titler   r   r_   r   r*   rL   rM   s   @rF   r   r      s     0//""&&(J
 !u  "H ,9J-u--!!%%'H
P P> >rN   r   c                   @     e Zd ZdZ G d d      Z fdZ fdZ xZS )OnboardingTaskFormz&
    Form for OnboardingTaskModel
    c                   N    e Zd ZdZeZdZddgZd ej                  ddi      iZ
y	)
OnboardingTaskForm.Meta<
        Meta class for add some additional options
        rY   rf   r[   r   r   z5oh-select oh-select-2 w-100 select2-hidden-accessiblerr   N)rH   rI   rJ   rK   r   r\   r-   r]   r   SelectMultiplerx   r^   rN   rF   r_   r   $  s@    	 {+.%.. WX
rN   r_   c                 z   t        	|   |i | t        t        j                  j                         t        dt        ddd| j                        d      | j                  d<   | j                  j                  d	      }|rt        j                  j                  |
      }|j                  }|j                  j                         }|| j                  d	   _        |j                   j                         j#                  dd      }t$        j                  j'                  |      }|| j                  d   _        y y )Nr   r   r   Tr   r   r   r'   rf   )idr   r   r   r   )r)   r*   r   r   r   r   r   r   r   r-   r2   r   r   recruitment_idonboarding_stager   r   r   r   r   )
r@   rA   rB   rf   r   recruitmentstage_querysetr   r   rE   s
            rF   r*   zOnboardingTaskForm.__init__2  s   $)&)%<%%))++":+,/%< "&
M" <<##J/#++//8/<E..K )99==?N/=DKK
#,!OO//1==nSW=XM%--44M4JM1>DKK%. rN   c                     t        | j                  d   t              r9| j                  j	                  d      }|r| j
                  j                  dd        t        | !          y Nr'   	r0   r-   r   r   r   r   r   r)   r   r@   idsrE   s     rF   r   zOnboardingTaskForm.cleanL  I    dkk-02IJ))##M2Ct4rN   )rH   rI   rJ   rK   r_   r*   r   rL   rM   s   @rF   r   r     s!    
 
?4 rN   r   c                   J     e Zd ZdZdZ G d d      Z fdZd Z fdZ xZ	S )OnboardingViewStageFormz'
    Form for OnboardingStageModel
    Stagec                   >    e Zd ZdZeZg dZ ed       ed      dZy)OnboardingViewStageForm.Metar   )stage_titler'   is_final_stagezStage TitlezIs Final Stage)r   r   N)	rH   rI   rJ   rK   r   r\   r-   rC   ry   r^   rN   rF   r_   r   [  s+    	  A]+ 01
rN   r_   c                    t        |   |i | t        | j                         t	        t
        j                  j                  d      t        dt        ddd| j                        d      | j                  d	<   | j                  j                         D ]I  \  }}t        t        j                               }|j                  j                   j#                  d
|i       K y)zN
        Initializes the form with custom field settings and widgets.
        T)r[   r   r   r   r   zStage Managersr   r'   r   N)r)   r*   r   r-   r   r   r   r   r   r   r   r.   struuiduuid4r/   r3   r4   )r@   rA   rB   r   rD   	unique_idrE   s         rF   r*   z OnboardingViewStageForm.__init__g  s     	$)&)$%<%%,,t,<+":+,/%< #&
M" "&!2!2!4 	9JDJJL)I LL%%tY&78		9rN   c                 &    d| i}t        d|      }|S )zS
        Render the form fields as HTML table rows with Bootstrap styling.
        formzcommon_form.htmlr
   )r@   rA   rB   context
table_htmls        rF   as_pzOnboardingViewStageForm.as_p  s      4.%&8'B
rN   c                     t        | j                  d   t              r9| j                  j	                  d      }|r| j
                  j                  dd        t        | !          y r   r   r   s     rF   r   zOnboardingViewStageForm.clean  r   rN   )
rH   rI   rJ   rK   verbose_namer_   r*   r   r   rL   rM   s   @rF   r   r   T  s-     L

 

94 rN   r   c                       e Zd ZdZ ej
                  d ed            Z ej
                  d ed            Z ej
                  d ed            Z	 ej
                  d ed            Z
 ej
                  d ed	            Z ej
                  d ed
            Z ej
                  d ed            Z ej
                  d ed            Z ej                  d ed            Z ej                  d ed            Z ej
                  d ed            Z ej
                  d ed            Z ej
                  d ed            Z G d d      Z fdZ xZS )EmployeeCreationFormz!
    Form for Employee Model
    Tz
First Namer   r8   Fz	Last NamePhoneAddressCountryStateZipQualification
ExperienceChildrenzEmergency Contact NumberzEmergency Contact NamezEmergency Contact Relationc                   6    e Zd ZdZeZdZdZd eddi      iZ	y)	EmployeeCreationForm.Metar}   rY   )employee_user_idemployee_profilerv   r[   additional_infois_from_onboardingis_directly_converteddobrq   r   rr   N)
rH   rI   rJ   rK   r   r\   r-   r]   r   rx   r^   rN   rF   r_   r     s2    	 
 9FF#34
rN   r_   c                     | j                   }|d   r|d   dk  rt        dt        d      i      |d   r|d   dk  rt        dt        d      i      t        |          S )N
experiencer   z'Experience should be a postive integierchildrenz+No of children should be a postive integier)r   r	   rC   r)   r   )r@   r   rE   s     rF   r   zEmployeeCreationForm.clean  s|    ((%,|*Dq*H!q!JKL  
#Z(@1(D!QLMN  w}rN   )rH   rI   rJ   rK   r   r   rC   employee_first_nameemployee_last_namephoneaddresscountrystatezipqualificationIntegerFieldr   r   emergency_contactemergency_contact_nameemergency_contact_relationr_   r   rL   rM   s   @rF   r   r     sY    *%//4qO(%q~NEOOT7<Eeoot1Y<@Geoot1Y<@GEOOT7<E
%//4qx
8C#EOOT?9KLM###T<IJ!u!!4q}EH'Q9: -U__Q78 "1Q;<"
 
( rN   r   c                      e Zd ZdZ ej
                  dd      Z ej
                  dd      Z ej
                  dd      Z ej                         Z
 ej
                  dd      Z ej
                  dd      Z ej
                  dd	      Z ej
                  dd
      Z ej
                  dd      Z G d d      Zy)BankDetailsCreationFormz*
    Form for BankDetailsCreationForm
    Tz	Bank Namer   zAccount NumberBranchr   r   CityzCode #1FzCode #2c                        e Zd ZdZeZdZg dZy)BankDetailsCreationForm.Metar}   rY   )r'   r   r[   N)rH   rI   rJ   rK   r   r\   r-   r]   r^   rN   rF   r_   r     s    	 $ArN   r_   N)rH   rI   rJ   rK   r   r   	bank_nameaccount_numberbranchr:   r   r   r   cityany_other_code1any_other_code2r_   r^   rN   rF   r   r     s      [AI$U__d:JKNU__d(;FennGeoot9=GEOOT9E5??D7D%eoot9EO%eoouIFOB BrN   r   )1rK   r   datetimer   typingr   djangor   django.contrib.auth.formsr   UserFormdjango.contrib.auth.modelsr   django.formsr   r	   django.template.loaderr   django.utils.translationr   rC   base.methodsr   employee.filtersr   employee.modelsr   r   horillar   2horilla_widgets.widgets.horilla_multi_select_fieldr   &horilla_widgets.widgets.select_widgetsr   onboarding.modelsr   r   r   recruitment.modelsr   r   rP   rV   rb   r   r   r   r   r   r^   rN   rF   <module>r     s   .     B + 3 3 6 ( + 9 ' V K L L (6 6r6LX 6Lr,) , 
i  
F,- ,=>Y =>@2 2j:i :z89 8vBi BrN   