
    vg                        d Z ddlZddlZddlZddlmZ ddlm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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! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z)m*Z* d Z+d Z,d Z-d Z. G d de%      Z/ G d de%      Z0 G d de%      Z1 eee1      d        Z2 G d  d!e%      Z3 G d" d#e%      Z4dd$l5m6Z6  G d% d&e%      Z7 G d' d(e%      Z8 G d) d*e%      Z9 G d+ d,e%      Z: G d- d.e%      Z; G d/ d0e%      Z< G d1 d2e%      Z= G d3 d4e%      Z> G d5 d6e%      Z? G d7 d8e%      Z@ G d9 d:e%      ZA G d; d<e%      ZB G d= d>e%      ZC G d? d@ej                        ZEg dAZFg dBZG G dC dDe%      ZH G dE dFe%      ZI eeeHj                  j                        dG        ZLdH ZMy)IzH
models.py

This module is used to register models for recruitment app

    N)date)uuid4)forms)settings)ValidationError)default_storage)MaxValueValidatorMinValueValidator)models)m2m_changed	post_save)receiver)gettext_lazy)HorillaCompanyManager)CompanyJobPosition)Employee)HorillaModelget_diff)HorillaAuditInfoHorillaAuditLogc                     d}t        j                  ||       .d| v rt        j                  d      t        j                  d      y)zT
    This method is used to validate the mobile number using regular expression
    z^\+[0-9 ]+$|^[0-9 ]+$N+zvInvalid input: Plus symbol (+) should only appear at the beginning                     or no other characters allowed.z2Invalid input: Only digits and spaces are allowed.)rematchr   r   )valuepatterns     &/var/www/horilla/recruitment/models.pyvalidate_mobiler    #   sV     'G	xx'%<''5  ##@
 	
 (    c                     t         j                  j                  | j                        d   }|j	                         dk7  rt        t        d            y)z-
    This method is used to validate pdf
       z.pdfzFile must be a PDF.N)ospathsplitextnamelowerr   _)r   exts     r   validate_pdfr+   4   sE     ''

5::
&q
)C
yy{fa 5677 r!   c                     | S )z3
    This method is used to validate the image
     )r   s    r   validate_imager.   =   s	     Lr!   c                     |j                  d      d   }| j                  j                  dd       d| dt                d| }t        j
                  j                  d|      S )N. r)   zrecruitment/profile/)splitr'   replacer   r$   r%   join)instancefilenamer*   s      r   candidate_photo_upload_pathr8   D   s[    
..
b
!C--''S12!H:QuwiqNH77<<.99r!   c            	           e Zd ZdZ ej
                  dd      Z ej                  dd      Z ej                  dd      Z
 ej                  eej                  dd ed      	      Z ed
      ZdefdZy)SurveyTemplatez
    SurveyTemplate Model
       T
max_lengthunique)nullblankF)defaulteditabler   	on_deleter?   r@   verbose_name
company_idreturnc                     | j                   S Ntitleselfs    r   __str__zSurveyTemplate.__str__[       zzr!   N)__name__
__module____qualname____doc__r   	CharFieldrK   	TextFielddescriptionBooleanFieldis_general_template
ForeignKeyr   CASCADEr)   rF   r   objectsstrrN   r-   r!   r   r:   r:   J   s     F48E"&""D9K-&--eeL"""..y\J $L1G r!   r:   c                   J     e Zd Z ej                  d      Zd Z fdZ xZS )Skilld   r=   c                     | j                   S rI   rJ   rL   s    r   rN   zSkill.__str__b   rO   r!   c                 f    | j                   }|j                         | _         t        |   |i | y rI   )rK   
capitalizesupersave)rM   argskwargsrK   	__class__s       r   re   z
Skill.savee   s-    

%%'
d%f%r!   )	rP   rQ   rR   r   rT   rK   rN   re   __classcell__rh   s   @r   r^   r^   _   s$    F,E& &r!   r^   c                       e Zd ZdZ ej
                  ddd      Z ej                  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                  edd      Z ej$                  eej&                  dddd e
d      d      Z ej*                  dd      Z ej                  e      Z ej                  ed      Z ej$                  eej&                  dd e
d            Z ej:                  ej>                  j@                  jB                        Z" ej:                  dd      Z# ej                  e$d      Z% e&       Z'ejP                  jS                         Z* ej                  d e
d            Z+ ej                  d e
d            Z, G d d      Z-d Z.d Z/ fdZ0 fdZ1d  Z2d! Z3 xZ4S )"Recruitmentz
    Recruitment model
    r;   T)r=   r?   r@   r?   Fz/To start recruitment for multiple job positions)rA   	help_textzFTo close the recruitment, If closed then not visible on pipeline view.zkTo publish a recruitment in website, if false then it             will not appear on open recruitment page.zyTo archive and un-archive a recruitment, if active is false then it             will not appear on recruitment list view.open_positions)related_namer@   recruitmentJob Position)rD   r?   r@   db_constraintrp   rE   rB   r   )rA   r?   r@   r   rC   rA   r@   r?   z2Profile image not mandatory for candidate creationz+Resume not mandatory for candidate creationc                       e Zd ZdZddgZdZy)Recruitment.Meta7
        Meta class to add the additional info
        )job_position_id
start_date)rz   r{   rF   ))archive_recruitmentzArchive RecruitmentN)rP   rQ   rR   rS   unique_togetherpermissionsr-   r!   r   Metarx      s     	
 <
 Hr!   r   c                 V    | j                   j                  d      j                         S )zR
        This method is used to get the count of
        hired candidates
        T)hired)	candidatefiltercountrL   s    r   total_hireszRecruitment.total_hires   s%    
 ~~$$4$06688r!   c                    | j                   1| j                  r%| j                  j                   d| j                   n| j                   }| j                  s1| j                  %| j
                  j                  | j                         |S )Nr2   )rK   rz   job_positionr{   is_event_basedro   add)rM   rK   s     r   rN   zRecruitment.__str__   sy     zz!d&:&: ##0014??2CD 	 ""t';';'G##D$8$89r!   c                 P   | j                   t        dt        d      i      | j                  r#| j                  dk  rt        t        d            | j
                  ;| j                  /| j                  | j
                  kD  rt        dt        d      i      t        | !         S )NrK   This field is requiredr   zCVacancy must be greater than zero if the recruitment is publishing.end_datez(End date cannot be less than start date.)	rK   r   r)   is_publishedvacancyr   r{   rd   cleanrM   rh   s    r   r   zRecruitment.clean   s    ::!7A.F,G"HII||q %]  ==$OO'DOOdmm,K!QIJK  w}r!   c                     t        |   |i | | j                  r#| j                  t	        dt        d      i      y y )Nro   r   )rd   re   r   ro   r   r)   )rM   rf   rg   rh   s      r   re   zRecruitment.save   sG    d%f%4#6#6#>!#3Q7O5P"QRR $?r!   c                 8    | j                   j                  d      S )zf
        This method will returns all the stage respectively to the ascending order of stages
        sequence)	stage_setorder_byrL   s    r   ordered_stageszRecruitment.ordered_stages   s     ~~&&z22r!   c                     t         j                  j                  | d      j                         }|rD|j                  j                         j                  d      }t        |      | j                  k\  ryyy)zj
        This method is used to check wether the vaccancy for the recruitment is completed or not
        r   recruitment_id
stage_typeT)canceledN)	Stager[   r   firstcandidate_setallexcludelenr   )rM   hired_stagehired_candidates      r   is_vacancy_filledzRecruitment.is_vacancy_filled   sq     mm**G + 

%' 	 )77;;=EEtETO?#t||3 4 r!   )5rP   rQ   rR   rS   r   rT   rK   rU   rV   rW   r)   r   closedr   	is_activeManyToManyFieldr   ro   rY   PROTECTrz   IntegerFieldr   r   recruitment_managersr:   survey_templatesr   rF   	DateFielddjangoutilstimezonenowr{   r   r^   skillsr   r[   managerManagerrA   optional_profile_imageoptional_resumer   r   rN   r   re   r   r   ri   rj   s   @r   rl   rl   k   s@    FTBE"&""-K(V((EFN !V  T
F '6&&7
L $##7
I ,V++"2$N (f''.."~&	O "f!!!$7G1611(;-v--nDI"""..y\J "!!&,,*?*?*C*CDJvd6H#V##E6F#%Gnn$$&G0V00#W!X *f))#P!QOH H9
&S
3
r!   rl   )senderc                     |rmt               }d|_        ||_        d|_        d|_        |j                          t               }d|_        ||_        d|_        d|_        |j                          yy)zT
    This is post save method, used to create initial stage for the recruitment
    r   Appliedappliedr#   InitialinitialN)r   r   r   stager   re   )r   r6   createdrg   applied_stageinitial_stages         r   create_initial_stager      sr    
 !"'/$'#, !"'/$'#,  r!   c            	          e Zd ZdZd ed      fd ed      fd ed      fd ed	      fd
 ed      fd ed      fgZ ej                  eej                  d ed            Z
 ej                  e      Z ej                  d      Z ej                  ded      Z ej"                  dd      Z ed      Zd Z G d d      Zd Zy)r   z
    Stage model
    r   r   r   r   testTest	interview	Interview	cancelled	Cancelledr   Hiredr   rl   )rD   rp   rE   2   r`      )r=   choicesrA   Tr   r?   rA   recruitment_id__company_idrelated_company_fieldc                     | j                    S rI   )r   rL   s    r   rN   zStage.__str__)      **r!   c                   "    e Zd ZdZdZddgZdgZy)
Stage.Metary   ))archive_StagezArchive Stager   r   r   N)rP   rQ   rR   rS   r~   r}   orderingr-   r!   r   r   r   ,  s    	 <+W5<r!   r   c                 J    dt         j                  j                  | dd      iS )zZ
        This method is used to get all the active candidate like related objects
        r   FT)stage_idr   r   )	Candidater[   r   rL   s    r   active_candidateszStage.active_candidates5  s0    
 9$$++ , 
 	
r!   N)rP   rQ   rR   rS   r)   stage_typesr   rY   rl   rZ   r   r   r   stage_managersrT   r   r   r   r   r   r[   rN   r   r   r-   r!   r   r   r     s    
 
AiL!	AiL!	6	an%	an%	!G*K 'V&&.. }%	N ,V++H5NF+E!!!{KJ #v""a8H#:VWG   
r!   r   c            
       |    e Zd ZdZd ed      fd ed      fd ed      fgZg dZd	 ed
      fd ed      fd ed      fgZ ej                  dd ed            Z
 ej                  ed      Z ej                  dd      Z ej                   eej$                  dd ed            Z ej                   eej$                  dd ed            Z ej                   eej$                  d ed            Z ej                   eej2                  ddd ed            Z ej6                  dd ed            Z ej:                  d d ed!      "      Z ej                  d#deg ed$      %      Z  ejB                  d&e"g'      Z# ej                   eejH                  ddd( ed)      *      Z% ejL                  dd ed+      d,-      Z' ej                  d.dd ed/      0      Z( ejR                  dd ed1      2      Z* ej                  d.dd ed3      0      Z+ ej                  d.dd ed4      0      Z, ej                  d.dd ed5      0      Z- ej                  d#edd ed6      7      Z. ej                  d8edd ed9      :      Z/ ej`                  d; ed<      =      Z1 ej`                  d; ed>      =      Z2 ej`                  d; ed?      =      Z3 ej`                  d; ed@      =      Z4 ejR                  dd edA            Z5 e6dBe7gC      Z8 ejr                  ddDE      Z: ejR                  dd;F      Z; ej                  dGedHd;I      Z< e=dJK      Z> ejR                  ddL      Z?de_@        dMdNgZAdO ZBdP ZCdQ ZDdR ZEdS ZFdT ZGdU ZHdV ZIdW ZJdX ZKdY ZL fdZZM G d[ d\      ZN xZOS )]r   z
    Candidate model
    maleMalefemaleFemaleotherOther))not_sentzNot Sent)sentSent)acceptedAcceptedrejectedRejected)joinedJoinedapplicationzApplication FormsoftwarezInside softwarer_   TName)r=   r?   rE   	upload_tor?      )r=   r@   r   rl   rD   r?   rp   rE   rr   rC   r   )rD   r?   rE   candidate_getr   )rD   r@   r?   rp   rE   zSchedule date)r@   r?   rE      Email)r=   r>   rE      Phone)r=   r@   
validatorsrE   recruitment/resumer   r   candidate_referralReferral)rD   r?   r@   rp   rE   Address   )r?   r@   rE   r=   r;   Country)r=   r?   r@   rE   zDate of Birth)r?   r@   rE   StateCityzZip CodeGender)r=   r   r?   rA   rE   r   Source)r=   r   r?   r@   rE   FzStart OnboardrA   rE   r   Canceled	ConvertedzJoining Datehistory_setrp   basesr   r   )r?   rB   
   r   )r=   r   rA   rB   r   r   )r?   auto_now)"stage_id__stage_managers__get_mailzStage Managers).recruitment_id__recruitment_managers__get_mailzRecruitment Managersc                     | j                    S rI   )r'   rL   s    r   rN   zCandidate.__str__  s    ))r!   c                     t         j                  j                  |       j                         }|r|j                  j                         dkD  S |S )z3
        Is offer rejected checking method
        candidate_idr   )RejectedCandidater[   r   r   reject_reason_idr   )rM   r   s     r   is_offer_rejectedzCandidate.is_offer_rejected  sH     "))00d0CIIK))//1A55r!   c                 ,    t        | j                        S )z7
        Method will return employee full name
        )r\   r'   rL   s    r   get_full_namezCandidate.get_full_name  s     499~r!   c                     d| j                          d}| j                  rA| j                  j                  }t        j                  |      r| j                  j
                  }|S )zV
        Method will rerun the api to the avatar or path to the profile image
        z!https://ui-avatars.com/api/?name=z&background=random)r  profiler'   r   existsurl)rM   r  full_filenames      r   
get_avatarzCandidate.get_avatar  sZ    
 00B0B0D/EEWX 	 << LL--M%%m4ll&&
r!   c           	      H    t        t        t        | dd      dd      dd      S )z;
        This method is used to return the company
        r   NrF   company)getattrrL   s    r   get_companyzCandidate.get_company  s-     GD"2D9<N
 	
r!   c                 .    | j                   j                  S )zQ
        This method is used to return the job position of the candidate
        )rz   r   rL   s    r   get_job_positionzCandidate.get_job_position  s     ##000r!   c                     | j                   S )z
        Return email
        )emailrL   s    r   	get_emailzCandidate.get_email  s     zzr!   c                 "    | j                         S )r2   )r&  rL   s    r   get_mailzCandidate.get_mail  s    ~~r!   c                     t        |       S )zS
        This method is used to return the tracked history of the instance
        r   rL   s    r   trackingzCandidate.tracking  s     ~r!   c                     ddl m} |j                  j                  | j                        j                  d      j                         S )z;
        This method is used to get last send mail
        r   )EmailLog)to__icontainsz-created_at)base.modelsr,  r[   r   r%  r   r   )rM   r,  s     r   get_last_sent_mailzCandidate.get_last_sent_mail	  s:     	) ##$**#=Xm$UW	
r!   c                 .   t         j                  j                  | j                        }|rid}|dz  }t	        |d      D ]K  \  }}|d| dz  }|d|j
                   dz  }|d	|j                   dz  }|d
|j                  rdnd dz  }M |dz  }|S y)zs
        This method is used to get the interview dates and times for the candidate for the mail templates
        r  z<table>zG<tr><th>Sl No.</th><th>Date</th><th>Time</th><th>Is Completed</th></tr>r#   )startz<tr><td>z</td>z<td class='dateformat_changer'>z<td class='timeformat_changer'>z<td>YesNoz
</td></tr>z</table> )InterviewScheduler[   r   id	enumerateinterview_dateinterview_time	completed)rM   
interviewsinterview_infoindexr   s        r   get_interviewzCandidate.get_interview  s    
 '..554775K
&NggN$-j$B 
 yHUG5"995i6N6N5OuU 5i6N6N5OuU I$7$75TB*M
 j(N!!r!   c                 X   | j                    | j                   j                  dk(  rd| _        | j                  j                  s'| j
                  | j                  j
                  | _        | j
                  | j                  j                  j                         vrt        dt        d      i      | j                  j                  r"| j
                  t        dt        d      i      | j                   r | j                   j                  dk(  rd| _
        | j                  rot        j                  j                  | j                  d      j                         }|s-t        j                  j                  | j                  ddd	
      }|| _         | j                   rft"        j                  j                  | j                         j%                  | j&                        j)                         rt        t        d            | j*                  rd| _        d| _
        t-        | \  |i | y )Nr   Trz   zChoose valid choicezThis field is required.r   r   zCancelled Candidatesr   )r   r   r   r   )converted_employee_id)r6  z!Employee is uniques for candidateF)r   r   r   r   r   rz   ro   r   r   r)   r   r   r[   r   r   creater@  r   r   r6  r  	convertedrd   re   )rM   rf   rg   cancelled_stagerh   s       r   re   zCandidate.save.  s   ==$}}''72!
""11d6J6J6R#'#6#6#F#FD t':':'I'I'M'M'OO!#4a8M6N"OPP--$2F2F2N!#4a8Q6R"STT==T]]55D DM==#mm22#22{ 3 eg  #"'--"6"6#'#6#60*	 #7 # ,DM&&!!((&*&@&@ )  WW VX	 "!$G"HII>>DJ!DMd%f%r!   c                       e Zd ZdZdZdZdgZy)Candidate.Metary   )r%  r   ))view_historyzView Candidate History)archive_candidatezArchive Candidater   N)rP   rQ   rR   rS   r}   r~   r   r-   r!   r   r   rE  Y  s    	

 <r!   r   )PrP   rQ   rR   rS   r)   r   offer_letter_statusessource_choicesr   rT   r'   
ImageFieldr8   r  URLField	portfoliorY   rl   r   r   r   rz   r   r   r   SET_NULLr@  DateTimeFieldschedule_date
EmailFieldr%  r    mobile	FileFieldr+   resumerZ   referralrU   addresscountryr   dobstatecityzipgendersourcerW   start_onboardr   r   rB  joining_dater   r   historyr   r   probation_endoffer_letter_statusr   r[   last_updatedexclude_from_automationmail_to_related_fieldsrN   r  r  r  r!  r#  r&  r(  r*  r/  r>  re   r   ri   rj   s   @r   r   r   @  sz    &	"Xq{$;gqz=RSG 
,-.	Q()*	!G*N
 6sAfINDf*EDQG3d;I&V&&.. }%N (f''..~&O !v  ..wZ	H .F--//$z] )F((Ao,>M FT'
SEV
 wZF V&
F !v  ..)z]H fAiLSG fD1Y<G &

Dq?Q
RCFD1W:E 6D1V9D &

D1Z=C Vx[F Vx[F (F''AoDVWMFAgJGE"v""5q}MH###E+OI#6##An,=L "
G #v""a8H$F$$$?M*&**%	 $:VWG#6##=L481@R

1 

2)&V   r!   r   )pre_bulk_updatec            	           e Zd ZdZ ej
                  d      Z ej                  ddd      Z ej                  e
ej                  dd ed            Z e       Zd	efd
Zy)RejectReasonz
    RejectReason
    r   r`   Tr   )r?   r@   r=   r   rC   rG   c                     | j                   S rI   rJ   rL   s    r   rN   zRejectReason.__str__~  rO   r!   N)rP   rQ   rR   rS   r   rT   rK   rU   rV   rY   r   rZ   r)   rF   r   r[   r\   rN   r-   r!   r   rg  rg  l  su     FE #&""DSIK"""..y\J $%G r!   rg  c                        e Zd ZdZ ej
                  eej                  dd      Z ej                  e
dd      Z ej                  d	      Z ed
      Z edeg      Zdef fdZ xZS )r  z
    RejectedCandidate
    r   rejected_candidate)rD   rE   rp   zReject reasonTrE   r@   r   r`   (candidate_id__recruitment_id__company_idr   r  r	  rG   c                      t         |          S rI   )rd   rN   r   s    r   rN   zRejectedCandidate.__str__  s    w  r!   )rP   rQ   rR   rS   r   OneToOneFieldr   r   r  r   rg  r  rU   rV   r   r[   r   r   r_  r\   rN   ri   rj   s   @r   r  r    s     (6''.. )	L .v--?$ #&""c2K#HG "
G! ! !r!   r  c                   <    e Zd Z ej                  ddd      Zd Zy)
StageFileszrecruitment/stageFilesT)r   r@   r?   c                 R    | j                   j                  j                  d      d   S )N/r1   )filesr'   r3   rL   s    r   rN   zStageFiles.__str__  s     zz$$S)"--r!   N)rP   rQ   rR   r   rR  rs  rN   r-   r!   r   rp  rp    s    F'?tRVWE.r!   rp  c                   n   e Zd ZdZ ej
                  eej                        Z ej                   e
d      d      Z ej
                  eej                        Z ej                  ed      Z ej
                  eej                  dd      Z ej&                  d	
      Z ed      ZdefdZd Zy)	StageNotez
    StageNote model
    rD   Descriptionr   rE   r=   Trt   )rD   r?   r@   Fru   rl  r   rG   c                     | j                    S rI   )rV   rL   s    r   rN   zStageNote.__str__  s    ""#$r!   c                 J    | j                   r| j                   S | j                  S rI   )
updated_byr  rL   s    r   updated_userzStageNote.updated_user  s    ????"$$$r!   N)rP   rQ   rR   rS   r   rY   r   rZ   r  rU   r)   rV   r   r   r   rp  stage_filesr   r{  rW   candidate_can_viewr   r[   r\   rN   r|  r-   r!   r   ru  ru    s     %6$$Y&..IL"&""-0@SQK v  &..AH(&((4@K"""FNNTJ -,,U;#HG% %%r!   ru  c                       e Zd ZdZd ed      fd ed      fd ed      fd ed	      fd
 ed      fd ed      fd ed      fd ed      fd ed      fd ed      fg
Z ej                  dd      Z ej                  e
dd      Z ej                  d      Z ej                  e ed            Z ej                  d      Z ej                  e ed       d!      Z ej$                  dd"#      Z ej(                  d$e%      Z ej                  dd& ed'      d(      Z ed)*      Zd+efd,Zd- Z fd.Z G d/ d0      Z xZS )1RecruitmentSurveyz!
    RecruitmentSurvey model
    checkboxzYes/NooptionsChoicesmultiplezMultiple ChoicetextTextnumberNumber
percentage
Percentager   DatetextareaTextareafilezFile UploadratingRatingFr   )r?   r=   TemplateTrk  ru   rl   rE   rm   zJob Positions)rE   rB   r   r   r   )r=   r   r4  zSeparate choices by ',  ')r?   rA   rn   r=   recruitment_ids__company_idr   rG   c                 ,    t        | j                        S rI   )r\   questionrL   s    r   rN   zRecruitmentSurvey.__str__  s    4==!!r!   c                 8    | j                   j                  d      S )z+
        Used to split the choices
        z, )r  r3   rL   s    r   r   zRecruitmentSurvey.choices  s     ||!!$''r!   c                     t        |   |i | | j                  \t        j                  j                  d      j                         }|r+| j                  j                  |       t        |   |i | y y y )NT)rX   )rd   re   template_idr:   r[   r   r   r   )rM   rf   rg   general_templaterh   s       r   re   zRecruitmentSurvey.save  s}    d%f%#-55<<$(  =  eg     $$%56d-f-  	 $r!   c                       e Zd ZdgZy)RecruitmentSurvey.Metar   N)rP   rQ   rR   r   r-   r!   r   r   r    s    
r!   r   )rP   rQ   rR   rS   r)   question_typesr   rU   r  r   r:   r  rW   is_mandatoryrl   recruitment_idsr   job_position_idsr   r   rT   typer  r   r[   r\   rN   r   re   r   ri   rj   s   @r   r  r    s   
 
Qx[!	AiL!	Q()*	6	1X;	q'	6	Qz]#	=!"	1X;N  vUs;H(&((ZtK '6&&u5L,f,,}%O  vU+H-v--!O"4u #v""a8H6D f2+F)GTWG $:WXG" "(.
 
r!   r  c                       e Zd ZdZ ej
                  eej                        Z ej
                  e	ej                        Z
 ej                  d      Z ed      Zy)QuestionOrderingz
    Survey Template model
    rv  r   ru   r  r   N)rP   rQ   rR   rS   r   rY   r  rZ   question_idrl   r   r   r   r   r[   r-   r!   r   r  r    sW     $&##$5PK&V&&{fnnMN"v""1-H#:WXGr!   r  c                   ^   e Zd ZdZ ej
                  eej                        Z ej
                  e	ej                   ed      d      Z ej
                  eej                   ed      d      Z ej                         Z ej"                  ddd      Z ed	
      Zed        ZdefdZy)RecruitmentSurveyAnswerz!
    RecruitmentSurveyAnswer
    rv  rl   T)rD   rE   r?   rr   recruitment_attachment)r   r?   r@   r   r   c                 x    	 t        j                  | j                        S # t         j                  $ r i cY S w xY w)z2
        Used to convert the json to dict
        )jsonloadsanswer_jsonJSONDecodeErrorrL   s    r   answerzRecruitmentSurveyAnswer.answer%  s6    	::d..//## 	I	s   ! 99rG   c                 L    | j                   j                   d| j                   S )N-)r  r'   r   rL   s    r   rN   zRecruitmentSurveyAnswer.__str__0  s'    ##(()4+>+>*?@@r!   N)rP   rQ   rR   rS   r   rY   r   rZ   r  rl   r   r)   r   r   rz   	JSONFieldr  rR  
attachmentr   r[   propertyr  r\   rN   r-   r!   r   r  r    s     %6$$Y&..IL&V&&..}%	N (f''..~&	O #&""$K!!!*TJ $:VWG A Ar!   r  c            	           e Zd Z ej                  dd      Z ej                         Z ej                  e	ddej                   ed            ZdefdZy)	RecruitmentMailTemplate   Tr<   r   r?   r@   rD   rE   rG   c                     | j                    S rI   rJ   rL   s    r   rN   zRecruitmentMailTemplate.__str__?  r   r!   N)rP   rQ   rR   r   rT   rK   rU   bodyrY   r   rZ   r)   rF   r\   rN   r-   r!   r   r  r  4  s[    F48E6D"""..y\J r!   r  c            	           e Zd ZdZ ej
                  dd      Z ej                   ed      d      Z	 ej                  eddej                   ed	      
      Z e       Zd ZdefdZy)	SkillZonez! "
    Model for talent pool
    r   
Skill Zoner=   rE   rw  r   rx  Tr   r  c                 D    t         j                  j                  d|       S )NT)r   skill_zone_id)SkillZoneCandidater[   r   rL   s    r   
get_activezSkillZone.get_activeS  s    !))004t0TTr!   rG   c                     | j                   S rI   rJ   rL   s    r   rN   zSkillZone.__str__V  rO   r!   N)rP   rQ   rR   rS   r   rT   rK   rU   r)   rV   rY   r   rZ   rF   r   r[   r  r\   rN   r-   r!   r   r  r  C  s{     FFE"&""-0@SQK"""..y\J $%GU r!   r  c            	       6    e Zd ZdZ ej
                  e ed      dej                  d      Z	 ej
                  e
ej                  dd ed            Z ej                  d ed	      
      Z ej                  d      Z ed      Z fdZdefdZ xZS )r  zB
    Model for saving candidate data's for future recruitment
    r  skillzonecandidate_setT)rE   rp   rD   r?   r   r   r   Reasonr  )auto_now_addrl  r   c           	      >   t         j                  j                  | j                  | j                        j                  | j                        j                         }|r/t        t        d| j                   d| j                   d            t        | -          y )N)r  r  )pkz
Candidate z already exists in Skill Zone r0   )r  r[   r   r  r  r   r  r  r   r)   rd   r   )rM   duplicate_existsrh   s     r   r   zSkillZoneCandidate.clean{  s     &&--!..d>P>P .  WW VX 	 ! !2!2 33QRVRdRdQeefg  	r!   rG   c                 H    t        | j                  j                               S rI   )r\   r  r  rL   s    r   rN   zSkillZoneCandidate.__str__  s    4$$22455r!   )rP   rQ   rR   rS   r   rY   r  r)   r   r  r   r  rT   reasonr   added_onr   r[   r   r\   rN   ri   rj   s   @r   r  r  Z  s     &F%%|_-..M %6$$..-{^L V1X;GFvT2H#HG&6 6r!   r  c                       e Zd Z ej                  eej                  d      Z ej                  eej                  d      Z	 ej                   ed       ed      g      Z G d d      Zdefd	Zy
)CandidateRatingcandidate_ratingrD   rp   r      )r   c                       e Zd ZddgZy)CandidateRating.Metaemployee_idr  N)rP   rQ   rR   r}   r-   r!   r   r   r    s    (.9r!   r   rG   c                 R    | j                    d| j                   d| j                   S )N - z rating )r  r  r  rL   s    r   rN   zCandidateRating.__str__  s+    ""#3t'8'8&9$++OOr!   N)rP   rQ   rR   r   rY   r   r   r  r   r  r   r
   r	   r  r   r\   rN   r-   r!   r   r  r    s    #&##FNN9KK %6$$V^^:LL !V  %a(*;A*>?F: :P Pr!   r  c                       e Zd ZdZ ej
                  d      Z ej
                  d      Z ej                  e	ej                  d      Zy)RecruitmentGeneralSettingz*
    RecruitmentGeneralSettings model
    Fru   TrD   r?   N)rP   rQ   rR   rS   r   rW   candidate_self_trackingshow_overall_ratingrY   r   rZ   rF   r-   r!   r   r  r    sI     2f11%@-&--e<"""7fnn4PJr!   r  c                   z   e Zd ZdZ ej
                  e ed      dej                        Z	 ej                  e ed            Z ej                   ed            Z ej                   ed            Z ej"                   ed	      d
d      Z ej&                  d ed            Z ed      ZdefdZy)r5  z$
    Interview Scheduling Model
    r   candidate_interview)rE   rp   rD   Interviewerr  zInterview DatezInterview Timerw  Tr   )rE   r@   r=   FzIs Interview Completedr  rl  rG   c                      | j                    dS )Nz -Interview.r  rL   s    r   rN   zInterviewSchedule.__str__  s    ##$L11r!   N)rP   rQ   rR   rS   r   rY   r   r)   rZ   r  r   r   r  r   r8  	TimeFieldr9  rU   rV   rW   r:  r   r[   r\   rN   r-   r!   r   r5  r5    s     %6$${^*..	L )&((-@PQK%V%%15E3FGN%V%%15E3FGN"&""}%TcK $##A&>$?I $$NOG2 2r!   r5  c                       e Zd Z ej                  deg      Z ej                  eej                  d      Z
 ej                  d      Zd Zy)	Resumer   r   rS  r  Fru   c                 8    | j                    d| j                   S )Nz
 - Resume )r   r  rL   s    r   rN   zResume.__str__  s    %%&j	::r!   N)rP   rQ   rR   r   rR  r+   r  rY   rl   rZ   r   rW   is_candidaterN   r-   r!   r   r  r    sW    6&
D 'V&&v~~HN '6&&u5L;r!   r  ))	requested	Requested)approvedApprovedr   ))anyAny)pdfPDF)txtTXT)docxDOCX)xlsxXLSX)jpgJPG)pngPNG)jpegJPEGc                       e Zd Z ej                  d      Z ej                  e      Z ej                  e	d      Z
 ej                  dd      Z ej                  ddd      Z ed	
      Zd Zy)CandidateDocumentRequestr_   r`   r  )r   r=   Trv   r   r@   r?   r=   +employee_id__employee_work_info__company_idr   c                     | j                   S rI   rJ   rL   s    r   rN   z CandidateDocumentRequest.__str__  rO   r!   N)rP   rQ   rR   r   rT   rK   r   r   r  FORMATSformatr   max_sizerU   rV   r   r[   rN   r-   r!   r   r  r    sv    F,E)6)))4LVg"=F"v""D9H"&""DSIK#KGr!   r  c                   B    e Zd Z ej                  d      Z ej                  eej                  d      Z	 ej                  e
ej                  d      Z ej                  dd      Z ej                  ed	d
      Z ej                   ddd      Zd Z fdZ xZS )CandidateDocument   r`   r   )rD   rE   Tr  zcandidate/documentsr   r  r  )r   r=   rA   r   r  c                 8    | j                    d| j                   S )Nr  )r  rK   rL   s    r   rN   zCandidateDocument.__str__  s    ##$C

|44r!   c                 "   t        |   |i | | j                  }t        | j                        dk  rt        dt        d      i      |r| j                  r| j                  j                  }| j                  j                  }|r+|j                  |dz  dz  kD  rt        dt        d      i      |j                  j                  d      d   j                         }|d	k(  ry ||k7  r%t        dt        d
      j                  |      i      y y y )N   rK   z#Title must be at least 3 charactersi   documentzFile size exceeds the limitr0   r#   r  zPlease upload {} file only.)rd   r   r  r   rK   r   r)   document_request_idr  r  sizer'   r3   r(   )rM   rf   rg   r  r  r  r*   rh   s          r   r   zCandidateDocument.clean  s   t&v&}}tzz?Q!7A.S,T"UVVD,,--44F//88H99x$55)#Q'D%EF  ))//#&q)//1C%#@!A!H!H!PQ   -4r!   )rP   rQ   rR   r   rT   rK   rY   r   r   r  r  r  rR  r  STATUSstatusrU   reject_reasonrN   r   ri   rj   s   @r   r   r     s    F,E$6$$V^^+L ,&++ FNN  v*?dKHVf[QF$F$$4dsKM5 r!   r   c                 H    |dk(  rt        |       y |dk(  rt        |       y y )Npost_addpost_remove)candidate_document_create)r   r6   actionrg   s       r   document_request_m2m_changedr     s'    !(+	=	 !(+ 
!r!   c                     | j                   j                         }|D ]Z  }t        j                  j	                  || dd| j
                   i      \  }}d| j
                   |_        |j                          \ y )NrK   zUpload )r  r  defaults)r  r   r   r[   get_or_createrK   re   )r6   
candidatesr   r  r   s        r   r  r  )  s~    &&**,J 	-55CC" ((89: D 
'
 #8>>"23r!   )NrS   r  r$   r   datetimer   uuidr   r   r   django.confr   django.core.exceptionsr   django.core.files.storager   django.core.validatorsr	   r
   	django.dbr   django.db.models.signalsr   r   django.dispatchr   django.utils.translationr   r)   base.horilla_company_managerr   r.  r   r   employee.modelsr   horilla.modelsr   horilla_audit.methodsr   horilla_audit.modelsr   r   r    r+   r.   r8   r:   r^   rl   r   r   r   horilla.signalsre  rg  r  rp  ru  r  r  r  r  r  r  r  r  r5  Modelr  r  r  r  r   r  throughr  r  r-   r!   r   <module>r'     s    	 	       2 5 G  ; $ 6 > , $ ' * B

"8:\ *	&L 	&K, K\ 
)K( )(/
L /
df  f R	 ,< ,! !:. .% %6>
 >
BY| Y$Al $ANl  .56 56pPl P$Q Q2 24;V\\ ; 
	| % %P 
+6CCKKL, M,	r!   