
    si                     l   d Z ddlZddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
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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' ddl(m)Z)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8 d Z9d Z:d Z;d Z< G d de0      Z= G d  d!e0      Z> G d" d#e0      Z? G d$ d%e0      Z@d& ZA G d' d(e0      ZB G d) d*e0      ZC G d+ d,e0      ZD G d- d.e0      ZE G d/ d0e0      ZF G d1 d2e0      ZG G d3 d4e0      ZH G d5 d6e0      ZI G d7 d8e0      ZJ G d9 d:e0      ZK G d; d<e0      ZL G d= d>e0      ZM G d? d@e0      ZN G dA dBej                        ZPg dCZQg dDZR G dE dFe0      ZS G dG dHe0      ZT G dI dJe0      ZUy)KzH
models.py

This module is used to register models for recruitment app

    N)datetimetimezone)	urlencode)uuid4)forms)settings)User)ValidationError)default_storage)MaxValueValidatorMinValueValidator)models)reversereverse_lazy)r   )format_html)slugify)gettext_lazy)HorillaCompanyManager)CompanyJobPosition)Employee)_thread_locals)HorillaModelupload_pathget_diff)HorillaAuditInfoHorillaAuditLogrender_templatec                     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     6/var/www/python-projects/worksol/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_pdfr3   ;   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_imager6   D   s	     Lr)   c                     |j                  d      d   }| j                  j                  dd       d| dt                d| }t        j
                  j                  d|      S )N. r1   zrecruitment/profile/)splitr/   replacer   r,   r-   join)instancefilenamer2   s      r'   candidate_photo_upload_pathr@   K   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 G d d      Zy)SurveyTemplatez
    SurveyTemplate Model
    2   T
max_lengthunique)nullblankF)defaulteditabler   	on_deleterG   rH   verbose_name
company_idreturnc                     | j                   S Ntitleselfs    r'   __str__zSurveyTemplate.__str__b       zzr)   c                   ,    e Zd Z ed      Z ed      Zy)SurveyTemplate.MetazSurvey TemplateSurvey TemplatesN__name__
__module____qualname__r1   rM   verbose_name_pluralr5   r)   r'   MetarY   e   s    *+ 23r)   r`   N)r\   r]   r^   __doc__r   	CharFieldrS   	TextFielddescriptionBooleanFieldis_general_template
ForeignKeyr   CASCADEr1   rN   r   objectsstrrV   r`   r5   r)   r'   rB   rB   Q   s     F48E"&""D9K-&--eeL"""..y\J $L1G 4 4r)   rB   c                        e Zd Z ej                  d      Zd Z fdZd Zd Z	d Z
d Zd	efd
Z G d d      Z xZS )Skilld   rE   c                     | j                   S rQ   rR   rT   s    r'   rV   zSkill.__str__m   rW   r)   c                 f    | j                   }|j                         | _         t        |   |i | y rQ   )rS   
capitalizesupersave)rU   argskwargsrS   	__class__s       r'   rs   z
Skill.savep   s-    

%%'
d%f%r)   c                 ~    t        t        j                  j                  d            }|j	                  |       dz   }|S )z$
        for get serial nos
        idr+   )listrl   ri   order_byindex)rU   all_instancessinos      r'   get_sinozSkill.get_sinou   s7     U]]33D9:""4(1,r)   c                 8    t        dd| j                  i      }|S )/
        This method to get update url
        zsettings-update-skillspkru   r   r   rU   urls     r'   get_update_urlzSkill.get_update_url}   s     3T477OL
r)   c                 B    t        d      }| j                  }| d| }|S )/
        This method to get delete url
        zdelete-skillsz?ids=r   )rU   base_urlskill_idr   s       r'   get_delete_urlzSkill.get_delete_url   s,      077
%z*
r)   c                     | j                   S )z,
        to get instance for delete
        r   rT   s    r'   get_delete_instancezSkill.get_delete_instance   s    
 wwr)   rO   c                     | j                    S rQ   rR   rT   s    r'   rV   zSkill.__str__   s    **r)   c                   ,    e Zd Z ed      Z ed      Zy)
Skill.Metarl   SkillsNr[   r5   r)   r'   r`   r      s    zkr)   r`   )r\   r]   r^   r   rb   rS   rV   rs   r~   r   r   r   rj   r`   __classcell__rv   s   @r'   rl   rl   j   sI    F,E&
 * *r)   rl   c                       e Zd ZdZ ej
                  ddd ed            Z ej                  d ed            Z	 ej                  d ed	      
      Z ej                  d ed       ed            Z ej                  d ed       ed            Z ej                  edd ed            Z ej"                  eej$                  dddd ed      d      Z ej(                  dd ed            Z ej                  e ed            Z ej                  ed ed            Z ej"                  eej$                  dd ed            Z ej8                  ej<                  j>                  j@                   ed            Z! ej8                  dd ed       !      Z" ej                  e#d ed"            Z$ ej"                  d#ej$                  dd ed$            Z% ej
                  d%dd&      Z& ej                  d ed'       ed(            Z' e(       Z)ejT                  jW                         Z, ej                  d ed)       ed*            Z- ej                  d ed+       ed,            Z. G d- d.      Z/d/ Z0d0 Z1 fd1Z2 fd2Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<d< Z=d= Z>d> Z?d? Z@d@ ZA xZBS )ARecruitmentz
    Recruitment model
    rC   TTitlerE   rG   rH   rM   Description)rG   rM   Fz/To start recruitment for multiple job positions)rI   	help_textzFTo close the recruitment, If closed then not visible on pipeline view.Closed)rI   r   rM   zkTo publish a recruitment in website, if false then it             will not appear on open recruitment page.zIs Publishedopen_positionsJob Position)related_namerH   rM   recruitment)rL   rG   rH   db_constraintr   rM   rJ   r   Vacancy)rI   rG   rM   ManagersrM   rZ   )rH   rM   r   rK   z
Start DaterI   rM   zEnd DaterH   rG   rM   r   zrecruitment.LinkedInAccountLinkedIn Account   )rE   rG   rH   zgTo publish a recruitment in Linkedin, if active is false then it             will not post on LinkedIn.zPost on LinkedInz2Profile image not mandatory for candidate creationzOptional Profile Imagez+Resume not mandatory for candidate creationzOptional Resumec                   <    e Zd ZdZddgZdZ ed      Z ed      Zy)Recruitment.Meta7
        Meta class to add the additional info
        )job_position_id
start_date)r   r   rN   ))archive_recruitmentzArchive Recruitmentr   RecruitmentsN)	r\   r]   r^   ra   unique_togetherpermissionsr1   rM   r_   r5   r)   r'   r`   r      s5    	
 <
 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countrT   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                         t        |      S )Nr:   )rS   r   job_positionr   is_event_basedr   addrj   )rU   rS   s     r'   rV   zRecruitment.__str__  s~     zz!d&:&: ##0014??2CD 	 ""t';';'G##D$8$895z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 )NrS   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.)	rS   r
   r1   is_publishedvacancyr   r   rr   clean)rU   rv   s    r'   r   zRecruitment.clean  s    ::!7A.F,G"HII||q %]  ==$OO'DOOdmm,K!QIJK  w}r)   c                     | j                   sd | _        d | _        t        |   |i | | j
                  r#| j                  t        dt        d      i      y y )Nr   r   )	publish_in_linkedinlinkedin_account_idlinkedin_post_idrr   rs   r   r   r
   r1   )rU   rt   ru   rv   s      r'   rs   zRecruitment.save,  s`    '''+D$$(D!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_setrz   rT   s    r'   ordered_stageszRecruitment.ordered_stages4  s     ~~&&z22r)   c                      t        dd| i      S )zD
        This method for get custom column for recruitment.
        z$cbv/recruitment/recruitment_col.htmlr>   r-   contextr   rT   s    r'   recruitment_columnzRecruitment.recruitment_column:  s    
 7&
 	
r)   c                 8    t        dd| j                  i      }|S )
        detail view
        zrecruitment-detail-viewr   r   r   r   r   s     r'   recruitment_detail_viewz#Recruitment.recruitment_detail_viewD  s     /twwH
r)   c                      t        dd| i      S )A
        This method for get custom column for managers.
        z!cbv/recruitment/managers_col.htmlr>   r   r   rT   s    r'   managers_columnzRecruitment.managers_columnK  s    
 4&
 	
r)   c                     | j                   j                         }|r.dj                  |D cg c]  }t        |       c}      }d| dS yc c}w )z(
        manager in detail view
        <br>+<span class="oh-timeoff-modal__stat-count"></span> )recruitment_managersallr=   rj   rU   	employeesemployeeemployee_names_strings       r'   managers_detailzRecruitment.managers_detailU  sY     --113	$*KK/898X9%! AAV@WW^__	 :   Ac           	          | j                   j                         }t        |      D cg c]  \  }}d|dz    d| d }}}dj                  |      S c c}}w )Nz<div>r+   z. </div>r   )r   r   	enumerater=   )rU   manager_listimanagerformatted_managerss        r'   managerszRecruitment.managersb  sd    00446?H?V
1;GeAE7"WIV,
 
 ww)**
s   Ac                      t        dd| i      S )r   z"cbv/recruitment/detail_action.htmlr>   r   r   rT   s    r'   detail_actionszRecruitment.detail_actionsi  s    
 5&
 	
r)   c                      t        dd| i      S )zB
        This method for get custom column for open jobs.
        zcbv/recruitment/open_jobs.htmlr>   r   r   rT   s    r'   open_job_colzRecruitment.open_job_cols  s    
 1&
 	
r)   c                     | j                   j                         }|r.dj                  |D cg c]  }t        |       c}      }d| dS yc c}w )z*
        open jobs in detail view
        r   r   r   r   )r   r   r=   rj   )rU   jobsjobjobs_names_strings       r'   open_job_detailzRecruitment.open_job_detail}  sX     ""&&( &,F#SX,F G=>O=PPWX  -Gr   c                      t        dd| i      S )zD
        This method for get custom column for Total hires.
        z cbv/recruitment/total_hires.htmlr>   r   r   rT   s    r'   	tot_hireszRecruitment.tot_hires  s    
 3&
 	
r)   c                     | j                   ryy)Nr   Open)closedrT   s    r'   
status_colzRecruitment.status_col  s    ;;r)   c                      t        dd| i      S )z@
        This method for get custom column for actions.
        zcbv/recruitment/actions.htmlr>   r   r   rT   s    r'   rec_actionszRecruitment.rec_actions  s    
 /&
 	
r)   c                 &    d| j                    d}|S zV
        Method will retun the api to the avatar or path to the profile image
        !https://ui-avatars.com/api/?name=&background=randomrR   r   s     r'   
get_avatarzRecruitment.get_avatar       2$**=OP
r)   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)	Stageri   r   firstcandidate_setr   excludelenr   )rU   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)   )Cr\   r]   r^   ra   r   rb   r1   rS   rc   rd   re   r   r   r   ManyToManyFieldr   r   rg   PROTECTr   IntegerFieldr   r   r   rB   survey_templatesr   rN   	DateFielddjangoutilsr   nowr   r   rl   skillsr   r   r   r   ri   r   ManagerrI   optional_profile_imageoptional_resumer`   r   rV   r   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   s   @r'   r   r      s=    FD1W:E #&""1];KLK(V((EFN !V  T
 x[F '6&&7
 ~&L ,V++%~&	N (f''.."~&	O "f!!!$Qy\RG1611(:W-v--d3E1F #""..y\J "!!%%)),J  vdAjMRH#V##EAhKPF+&++%..)* (v''3TN-&--(
 )* $%Gnn$$&G0V00HI/0
 *f))AB()O0 0 9
&S3

+




r)   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 ed            Z ej                  d ed             Z ej                  ded ed            Z ej"                  dd      Z ed      Z G d d      Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zd& Zd' Zd( Zd) Z d* Z!d+ Z"d, Z#y-).r  z
    Stage model
    initialInitialappliedAppliedtestTest	interview	Interview	cancelled	Cancelledr   Hiredr   r   )rL   r   rM   Stage Managersr   rC   rE   rM      z
Stage Type)rE   choicesrI   rM   Tr   rG   rI   recruitment_id__company_idrelated_company_fieldc                   B    e Zd ZdZdZddgZdgZ ed      Z ed      Z	y)	
Stage.Metar   ))archive_StagezArchive Stager  stager   r  StagesN)
r\   r]   r^   ra   r   r   orderingr1   rM   r_   r5   r)   r'   r`   r.    s2    	 <+W5<zkr)   r`   c                 N    | j                    d| j                  j                   dS )Nz - ())r0  r  rS   rT   s    r'   rV   zStage.__str__  s&    **T$"5"5";";!<A>>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  	is_active)	Candidateri   r   rT   s    r'   active_candidateszStage.active_candidates  s0    
 9$$++ , 
 	
r)   c                 8    t        dd| j                  i      }|S )r   zstage-detail-viewr   r   r   r   s     r'   stage_detail_viewzStage.stage_detail_view  s     )4/B
r)   c                      t        dd| i      S )z2
        For answerable employees  column
        zcbv/stages/detail_action.htmlr>   r   r   rT   s    r'   detail_actionzStage.detail_action  s    
 0&
 	
r)   c                      t        dd| i      S )z@
        This method for get custome coloumn for title.
        zcbv/stages/title.htmlr>   r   r   rT   s    r'   	title_colzStage.title_col  s     (&
 	
r)   c                      t        dd| i      S )zC
        This method for get custome coloumn for managers.
        zcbv/stages/managers.htmlr>   r   r   rT   s    r'   managers_colzStage.managers_col  s    
 +&
 	
r)   c                 &    d| j                    d}|S r   r  r   s     r'   r   zStage.get_avatar  s$    
 00C0C/DDVW 	 
r)   c                     | j                   j                         }dj                  |D cg c]  }t        |       c}      }|S c c}w z(
        Manager in detail view
        r   )stage_managersr   r=   rj   r   s       r'   detail_managers_colzStage.detail_managers_col  sB     ''++-	 &9,UxS],U V$$ -V   Ac                      t        dd| i      S )zB
        This method for get custome coloumn for actions.
        zcbv/stages/actions.htmlr>   r   r   rT   s    r'   actions_colzStage.actions_col#  s    
 *&
 	
r)   c                     dt        d      fdt        d      fdt        d      fdt        d      fd	t        d
      fg}t        |      j                  | j                        S )z
        Display type
        r  r  r  r  r   r!  r"  r#  r   r$  )r1   dictgetr  )rU   stage_typess     r'   get_typezStage.get_type-  sc    
 )%QvY!K.)!K.)aj!
 K $$T__55r)   c                 4    t        dd| j                  i      S )r   zstage-update-pipeliner   r   )r   rx   rT   s    r'   get_stage_update_urlzStage.get_stage_update_url;  s     .dggGGr)   c                 6    t        d       d| j                   S )z6
        This method to get add candidate url
        zadd-candidate-to-stage
?stage_id=r   rx   rT   s    r'   get_add_candidate_urlzStage.get_add_candidate_urlA  s      789DGG9MMr)   c                 6    t        d       d| j                   S )z3
        This method to get send email url
        	send-mailrS  rT  rT   s    r'   get_send_email_urlzStage.get_send_email_urlG  s     {+,Jtwwi@@r)   c                 6    t        d       d| j                   S )r   generic-deletez?model=recruitment.Stage&pk=r   rT   s    r'   r   zStage.get_delete_urlM  s!     /011MdggYWWr)   N)$r\   r]   r^   ra   r1   rN  r   rg   r   rh   r  r  r   rF  rb   r0  r  r  r   r   ri   r`   rV   r9  r;  r=  r?  rA  r   rG  rJ  rO  rQ  rU  rX  r   r5   r)   r'   r  r    sL   
 
AiL!	AiL!	6	an%	an%	!G*K 'V&&.. }%	N ,V++H1EUCVWNF7DE!!!|_	J #v""a8H#:VWG	* 	*?



%
6HNAXr)   r  c                     |j                  d      d   }t        | j                        xs d}| dt               j                  dd  d| }d| d| S )	zN
    Generates a unique file path for candidate profile & resume uploads.
    r8   r9   r   -N   zrecruitment//)r;   r   r/   r   hex)r>   r?   r2   	name_slugunique_filenames        r'   candidate_upload_pathrb  T  sa     ..
b
!C&5+I"1UW[[!_$5Qse<O)Ao%677r)   c            
        	    e Zd ZdZd ed      fd ed      fd ed      fgZd ed	      fd
 ed      fd ed      fd ed      fd ed      fg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                  ee"g/      Z# ej                   eejH                  ddd0 ed1      2      Z% ejL                  dd ed3      d45      Z' ej                  d6dd ed7      8      Z( ejR                  dd ed9      :      Z* ej                  d6dd ed;      8      Z+ ej                  d6dd ed<      8      Z, ej                  d6dd ed=      8      Z- ej                  d,edd ed>      ?      Z. ej                  d@edd edA      B      Z/ ej`                  dC edD      E      Z1 ej`                  dC edF      E      Z2 ej`                  dC edG      E      Z3 ej`                  dC edH      E      Z4 ejR                  dd edI      (      Z5 e6dJe7gK      Z8 ejr                  ddLM      Z: ejR                  ddCN      Z; ej                  dOeddC edP      Q      Z< e=dRS      Z> ejR                  ddT      Z?de_@        dUdVgZA ejR                  dddCW      ZBdX ZCdY ZDdZ ZEd[ ZFd\ ZGd] ZHd^ ZId_ ZJd` ZKda ZLdb ZMdc ZNdd ZOde ZPdf ZQdg ZRdh ZSdi ZTdj ZUdk ZVdl ZWdm ZXdn ZYdo ZZdp Z[dq Z\dr Z]ds Z^dt Z_du Z`dv Zadw Zbdx Zcdy Zddz Zed{ Zfd| Zgd} Zhd~ Zid Zjd Zkd Zld Zmd Znd Zod Zp fdZqd Zrd Zsd Ztd Zud Zvd Zw G d d      Zx xZyS )r8  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 softwarerm   TName)rE   rG   rM   	upload_torG      )rE   rH   r   r   rL   rG   r   rM   r   rK   r  rL   rG   rM   candidate_getr   )rL   rH   rG   r   rM   zSchedule dater      Email)rE   rF   rM      Mobile)rE   rH   
validatorsrM   rw  r  candidate_referralReferral)rL   rG   rH   r   rM   Address   )rG   rH   rM   rE      Countryr   zDate of Birth)rG   rH   rM   StateCityzZip CodeGender)rE   r(  rG   rI   rM   r'  Source)rE   r(  rG   rH   rM   FzStart Onboardr   r$  Canceled	ConvertedzJoining Datehistory_setr   basesr   r)  )rG   rJ   
   zOffer Letter Status)rE   r(  rI   rJ   rM   r*  r+  )rG   auto_now)"stage_id__stage_managers__get_mailr%  ).recruitment_id__recruitment_managers__get_mailzRecruitment Managers)rG   rH   rJ   c                     | j                    S rQ   )r/   rT   s    r'   rV   zCandidate.__str__  s    ))r)   c                    t        t        dd      }t        |di       }|j                  | j                  j                  j
                        ^t        j                  j                  | j                  j                        }||| j                  j                  j
                  <   ||_	        t        d| |j                  | j                  j                  j
                     d      S )z!
        Stage drop down
        requestNall_rec_stagesrC  z!cbv/pipeline/stage_drop_down.html)r>   stagesr   )getattrr   rM  r6  r  r   r  ri   r   r  r    )rU   r  r  r  s       r'   stage_drop_downzCandidate.stage_drop_down  s     .)T: *:B?dmm::==>F]]))9U9U)VF>DN4==77::;%3G"4 !001M1M1P1PQ
 	
r)   c                      t        dd| i      S )
        Rating bar
        zcbv/pipeline/rating.htmlr>   r   r   rT   s    r'   
rating_barzCandidate.rating_bar  s     +j$5G
 	
r)   c                      t        dd| i      S )z,
        Scheduled interviews count
        z%cbv/pipeline/count_of_interviews.htmlr>   r   r   rT   s    r'   get_interview_countzCandidate.get_interview_count  s     8:tBT
 	
r)   c                      t        dd| i      S )r  zcbv/pipeline/mail_status.htmlr>   r   r   rT   s    r'   mail_indicationzCandidate.mail_indication  s     0:t:L
 	
r)   c                 J    t        j                         }t        d| |d      S )r  z"cbv/pipeline/candidate_column.htmlr>   r  r   )tzr  r    rU   r  s     r'   candidate_namezCandidate.candidate_name  s'     ffh5!%c2
 	
r)   c                     | j                   S )z1
        to get contact no of candidates
        mobilerT   s    r'   get_contactzCandidate.get_contact  s     {{r)   c                 .    | j                   j                  S rQ   )resumer   rT   s    r'   get_resume_urlzCandidate.get_resume_url%  s    {{r)   c                 B    t        d| j                  j                        S )NzJ<div class="oh-checkpoint-badge oh-checkpoint-badge--secondary">{}/4</div>)r   onboarding_portalr   rT   s    r'   onboarding_portal_htmlz Candidate.onboarding_portal_html(  s!    X""((
 	
r)   c                      t        dd| i      S )zA
        This method for get custome coloumn for rating.
        zcbv/candidates/rating.htmlr>   r   r   rT   s    r'   ratingzCandidate.rating.      
 -&
 	
r)   c                      t        dd| i      S )zA
        This method for get custome coloumn for status.
        zcbv/onboarding_view/status.htmlr>   r   r   rT   s    r'   onboarding_status_colzCandidate.onboarding_status_col8  s    
 2&
 	
r)   c                     ddl m}m} | j                  j                  }|j
                  j                  |      }|j                  }t        d| ||dd      S )z@
        This method for get custome coloumn for tasks.
        r   )CandidateStageCandidateTaskrx   zcbv/onboarding_view/task.htmlT)r>   r   r(  single_viewr   )	onboarding.modelsr  r  onboarding_stagerx   ri   rM  choicer    )rU   r  r  
cand_stagecand_stage_objr(  s         r'   onboarding_task_colzCandidate.onboarding_task_colB  s^     	D**--
'//33z3B&&0 +"#	
 	
r)   c                     | j                   ryy)z 
        archive status
        Archivez
Un-Archive)r7  rT   s    r'   archive_statuszCandidate.archive_statusV  s     >>r)   c                      t        dd| i      S )zA
        This method for get custome coloumn for resume.
        zcbv/candidates/resume.htmlr>   r   r   rT   s    r'   
resume_pdfzCandidate.resume_pdf_  r  r)   c                 2   t        t        dd      }t        |dd      }|s7t        t        j                  j                  dd            }t        |d|       t        j                  j                  |      j                  dd      }t        d| |d	
      S )zA
        This method for get custom coloumn for options.
        r  NmailsemailTflat)username__inzcbv/candidates/option.html)r>   emp_listr   )
r  r   ry   r8  ri   values_listsetattrr	   r   r    )rU   r  r  r  s       r'   optionszCandidate.optionsi  s    
 .)T:$/**66wT6JKEGWe,<<&&E&:FF$ G 
 -!%8<
 	
r)   c                 8    t        dd| j                  i      }|S )z0
        This method to get profile url
        zcandidate-viewr   r   r   r   s     r'   get_profile_urlzCandidate.get_profile_url~  s     +T477OD
r)   c                 8    t        dd| j                  i      }|S )r   zrec-candidate-updatecand_idr   r   r   s     r'   r   zCandidate.get_update_url       19dgg:NO
r)   c                 8    t        dd| j                  i      }|S )r   to-skill-zoner  r   r   r   s     r'   get_skill_zone_urlzCandidate.get_skill_zone_url       ?Itww3GH
r)   c                 T    t        d      }t        d| j                  i      }| d| S )V
        This method to get the update URL with cand_id as a query parameter.
        add-to-rejected-candidatescandidate_id?r   r   r   rU   r   query_paramss      r'   get_rejected_candidate_urlz$Candidate.get_rejected_candidate_url  3       <= .$''!:;1\N++r)   c                 T    t        d      }t        d| j                  i      }| d| S )r  candidate-document-requestr  r  r  r  s      r'   get_document_requestzCandidate.get_document_request  r  r)   c                 8    t        dd| j                  i      }|S )r   z	view-noter  r   r   r   s     r'   get_view_note_urlzCandidate.get_view_note_url       ;	477/CD
r)   c                 8    t        dd| j                  i      }|S r   zcandidate-view-individualr  r   r   r   s     r'   get_individual_urlzCandidate.get_individual_url       6	477?ST
r)   c                 8    t        dd| j                  i      }|S r  r   r   s     r'   get_push_urlzCandidate.get_push_url  r  r)   c                 8    t        dd| j                  i      }|S )z;
        This method to get covert to employee url
        zcandidate-conversionr  r   r   r   s     r'   get_convert_to_empzCandidate.get_convert_to_emp  r  r)   c                 8    t        dd| j                  i      }|S )zC
        This method to get add to skill zone employee url
        r  r  r   r   r   s     r'   get_add_to_skillzCandidate.get_add_to_skill  r  r)   c                 :    t        d      }| d| j                   S )zD
        This method to get add to reject zone employee url
        r  ?candidate_id=r   r   s     r'   get_add_to_rejectzCandidate.get_add_to_reject  s$     78nTWWI..r)   c                 t    | j                   rd}nd}d| d}t        dd| j                  i      }d| d	| dS )
z1
        This method to get archive  url
        archivez
un-archivezDo you want to z this candidate?zrec-candidate-archiver  r   'z',')r7  r   r   )rU   actionmessager   s       r'   get_archive_urlzCandidate.get_archive_url  sO    
 >>F!F#F8+;<2Itww;OP3%s7)1%%r)   c                     t        d      }|S )r   rZ  )r   r   s     r'   r   zCandidate.get_delete_url  s     +,
r)   c                 8    t        dd| j                  i      }|S )z6
        This method to get self tracking url
        zcandidate-self-status-trackingr  r   r   r   s     r'   get_self_tracking_urlzCandidate.get_self_tracking_url  s#     ,i5I
 
r)   c                 <    t        d      d| j                   z   }|S )z9
        This method to get document request url
        r  r  r   r   s     r'   get_document_request_docz"Candidate.get_document_request_doc  s$     78^DGG9;UU
r)   c                     t        t        dd      }t        |dd      s#t        j                  j	                         |_        |j
                  j                  | j                        j                         ryy)z6
        The method to get converted employee
        r  Nr   r  z"style="background-color: #f1ffd5;")	r  r   r   ri   r   r   r   r  exists)rU   r  s     r'   is_employee_convertedzCandidate.is_employee_converted  sa     .)T:wT2 ( 0 0 4 4 6G##$**#5<<>7 ?r)   c                 8    t        dd| j                  i      }|S )"
        Candidate detail
        zcandidate-detailr   r   r   r   s     r'   get_details_candidatezCandidate.get_details_candidate  s     -tTWWoF
r)   c                 8    t        dd| j                  i      }|S )r  rW  r  r   r   r   s     r'   get_send_mailzCandidate.get_send_mail  r  r)   c                     t         j                  j                  |       j                         }|r|j                  j                         dkD  S |S )z3
        Is offer rejected checking method
        r  r   )RejectedCandidateri   r   r  reject_reason_idr   )rU   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
        )rj   r/   rT   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
        r   r   )r  profiler/   r   r  r   )rU   r   full_filenames      r'   r   z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  NrN   company)r  rT   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
        )r   r   rT   s    r'   get_job_positionzCandidate.get_job_position4  s     ##000r)   c                     | j                   S )z
        Return email
        r  rT   s    r'   	get_emailzCandidate.get_email:  s     zzr)   c                 "    | j                         S )r:   )r  rT   s    r'   get_mailzCandidate.get_mail@  s    ~~r)   c                     | j                   S rQ   r  rT   s    r'   phonezCandidate.phoneD  s    {{r)   c                     t        |       S )zS
        This method is used to return the tracked history of the instance
        r   rT   s    r'   trackingzCandidate.trackingG  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#  ri   r   r  rz   r  )rU   r#  s     r'   get_last_sent_mailzCandidate.get_last_sent_mailM  s:     	) ##$**#=Xm$UW	
r)   c                 8    t        dd| j                  i      }|S )Nzinterview-scheduler  r   r   r   s     r'   get_schedule_interviewz Candidate.get_schedule_interviewY  s    /DGG8LM
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)z{
        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>r   )InterviewScheduleri   r   rx   r   interview_dateinterview_time	completed)rU   
interviewsinterview_infor{   r   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                 v    t         j                  j                  | j                        }t	        d| |d      S )Nr  z$cbv/pipeline/interview_template.html)r>   r1  r   )r-  ri   r   r   r    )rU   r1  s     r'   candidate_interview_viewz"Candidate.candidate_interview_vieww  s7    &..554775K
7!%Z@
 	
r)   c                 T   | j                   | j                   j                  dk(  | _        | 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   r   zChoose valid choicezThis field is required.r"  Tr  zCancelled CandidatesrC   )r  r0  r  r   )converted_employee_idr  z!Employee is uniques for candidateF)r6  r  r   r  r   r   r   r   r
   r1   r  r  ri   r   r  creater7  r8  r  rx   r  	convertedrr   rs   )rU   rt   ru   cancelled_stagerv   s       r'   rs   zCandidate.save~  s   ==$11W<DJ""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                      t        dd| i      S )z,
        for last send mail column

        z)cbv/onboarding_candidates/cand_email.htmlr>   r   r   rT   s    r'   
last_emailzCandidate.last_email  s     <&
 	
r)   c                      t        dd| i      S )z*
        for joining date column

        z.cbv/onboarding_candidates/date_of_joining.htmlr>   r   r   rT   s    r'   date_of_joiningzCandidate.date_of_joining  s     A&
 	
r)   c                      t        dd| i      S )z,
        for probation date column

        z-cbv/onboarding_candidates/probation_date.htmlr>   r   r   rT   s    r'   probation_datezCandidate.probation_date  s     @&
 	
r)   c                      t        dd| i      S )z+
        for offer letter  column

        z+cbv/onboarding_candidates/offer_letter.htmlr>   r   r   rT   s    r'   offer_letterzCandidate.offer_letter  s     >&
 	
r)   c                 ^    | j                         rdt        d       dS dt        d       dS )z]
        Returns the appropriate style and title attributes for rejected candidates.
        z?style="background: #ff4500a3 !important; color: white;" title="zAdded In Rejected Candidates"ztitle="zAdd To Rejected Candidates)r  r1   rT   s    r'   rejected_candidate_classz"Candidate.rejected_candidate_class  s>     !!#TUVWuUvTwwxyyQ;<=Q??r)   c                      t        dd| i      S )z&
        for actions  column

        z&cbv/onboarding_candidates/actions.htmlr>   r   r   rT   s    r'   actionszCandidate.actions  s     9&
 	
r)   c                   >    e Zd ZdZdZdZdgZ ed      Z ed      Z	y)Candidate.Metar   )r  r  ))view_historyzView Candidate History)archive_candidatezArchive Candidater   r8  
CandidatesN)
r\   r]   r^   ra   r   r   r2  r1   rM   r_   r5   r)   r'   r`   rI    s1    	

 <~or)   r`   )zr\   r]   r^   ra   r1   r(  offer_letter_statusessource_choicesr   rb   r/   
ImageFieldr   r  URLField	portfoliorg   r   r  r  r   r   r  r6  r   SET_NULLr7  DateTimeFieldschedule_date
EmailFieldr  r(   r  	FileFieldr3   r  rh   referralrc   addresscountryr  dobstatecityzipgendersourcere   start_onboardr   r  r9  joining_dater   r   historyr  r   probation_endoffer_letter_statusr   ri   last_updatedexclude_from_automationmail_to_related_fields
hired_daterV   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r
  r  r  r   r  r  r  r  r  r!  r&  r(  r3  r5  rs   r<  r>  r@  rB  rE  rG  r`   r   r   s   @r'   r8  r8  ^  s    &	"Xq{$;gqz=RSG	Qz]#	6	Qz]#	Qz]#	1X; 
,-.	Q()*	!G*N
 6sAfINDf+DAG3d;I&V&&.. }%N (f''..~&O !v  ..wZ	H .F--//$z] )F((Ao,>M FT'
SEV
 x[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 "!!t4%HJ
$







( 

*,,/&	8
1 

4
&&P	
	
	
	
@	
. .r)   r8  c            	           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d Zd Zd Z G d d      Zy)RejectReasonz
    RejectReason
    rC   rn   Tr  )rG   rH   rE   r   rK   rO   c                     | j                   S rQ   rR   rT   s    r'   rV   zRejectReason.__str__
  rW   r)   c                 8    t        dd| j                  i      }|S )r   zupdate-reject-reason-viewr   r   r   r   s     r'   r   zRejectReason.get_update_url  s    
 6dggO
r)   c                 B    t        d      }| j                  }| d| }|S )r   zdelete-reject-reasonsz?id=r   )rU   r   rej_idr   s       r'   r   zRejectReason.get_delete_url  s-       78
$vh'
r)   c                     | j                   S rQ   r  rT   s    r'   get_instance_idzRejectReason.get_instance_id  s    wwr)   c                   ,    e Zd Z ed      Z ed      Zy)RejectReason.MetazReject ReasonzReject ReasonsNr[   r5   r)   r'   r`   rr  !  s    ) 01r)   r`   N)r\   r]   r^   ra   r   rb   rS   rc   rd   rg   r   rh   r1   rN   r   ri   rj   rV   r   r   rp  r`   r5   r)   r'   rj  rj    s     FE #&""DSIK"""..y\J $%G 2 2r)   rj  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dZy)r  z
    RejectedCandidate
    r8  rejected_candidate)rL   rM   r   zReject reasonTrM   rH   r  rn   (candidate_id__recruitment_id__company_idr+  r  r  rO   c                     dj                  | j                  j                  dd            }| j                   d|r| S d S )N, rS   Tr   - z	No Reason)r=   r  r  r  )rU   reasonss     r'   rV   zRejectedCandidate.__str__?  sL    ))D11==gD=QR##$C7'LMM'LMMr)   N)r\   r]   r^   ra   r   OneToOneFieldr8  r  r  r  rj  r  rc   rd   r   ri   r   r   rb  rj   rV   r5   r)   r'   r  r  &  s     (6''.. )	L .v--?$ #&""c2K#HG "
GN Nr)   r  c                   <    e Zd Z ej                  edd      Zd Zy)
StageFilesT)rw  rH   rG   c                 R    | j                   j                  j                  d      d   S )Nr^  r9   )filesr/   r;   rT   s    r'   rV   zStageFiles.__str__G  s     zz$$S)"--r)   N)r\   r]   r^   r   rV  r   r  rV   r5   r)   r'   r}  r}  D  s    F{$TJE.r)   r}  c                   l   e Zd ZdZ ej
                  eej                        Z ej                   e
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
    rL   r   r   T)rH   )rL   rG   rH   FrI   rv  r+  rO   c                     | j                    S rQ   )rd   rT   s    r'   rV   zStageNote.__str__\  s    ""#$r)   c                 J    | j                   r| j                   S | j                  S rQ   )
updated_byr  rT   s    r'   updated_userzStageNote.updated_user_  s    ????"$$$r)   N)r\   r]   r^   ra   r   rg   r8  rh   r  rc   r1   rd   r  r6  r  r}  stage_filesr   r  re   candidate_can_viewr   ri   rj   rV   r  r5   r)   r'   r  r  K  s     %6$$Y&..IL"&""-0@AK v  &..AH(&((4@K"""FNNTJ -,,U;#HG% %%r)   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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d. Zd/ Zd0 Zd1 Zd2 Z  fd3Z! G d4 d5      Z" xZ#S )6RecruitmentSurveyz!
    RecruitmentSurvey model
    checkboxzYes/Nor  ChoicesmultiplezMultiple ChoicetextTextnumberNumber
percentage
PercentagedateDatetextareaTextareafilezFile Uploadr  RatingFr  )rG   rE   TemplateTru  r  r   r   )rG   zJob Positions)rM   rJ   r   r)  r~  )rE   r(  r   zSeparate choices by ',  ')rG   rI   r   rE   recruitment_ids__company_idr+  rO   c                 ,    t        | j                        S rQ   )rj   questionrT   s    r'   rV   zRecruitmentSurvey.__str__      4==!!r)   c                 |    | j                   dk(  s| j                   dk(  r| j                  rd| j                   dS dS y)Nr  r  z<<div class='oh-timeoff-modal__stat-title'>Options</div><div>r   r   )typer  rT   s    r'   options_colzRecruitmentSurvey.options_col  sJ    99	!TYY*%< << Ot||n\bc 
 r)   c                 8    t        dd| j                  i      }|S )Nz)recruitment-survey-question-template-editr   r   r   r   s     r'   get_edit_urlzRecruitmentSurvey.get_edit_url  s     7tww
 
r)   c                 8    t        dd| j                  i      }|S )Nz+recruitment-survey-question-template-delete	survey_idr   r   r   s     r'   r   z RecruitmentSurvey.get_delete_url  s$    9;PTPWPWBX
 
r)   c                     | j                   j                         }dj                  |D cg c]  }t        |       c}      }|S c c}w rE  )recruitment_idsr   r=   rj   )rU   r   recrecruitment_strings       r'   recruitment_colz!RecruitmentSurvey.recruitment_col  sB     **..0#[[k)Js#c()JK!! *KrH  c                 ^    t        | j                        j                  | j                        S rQ   )rL  question_typesrM  r  rT   s    r'   get_question_typez#RecruitmentSurvey.get_question_type  s"    D''(,,TYY77r)   c                 8    | j                   j                  d      S )z+
        Used to split the choices
        rx  )r  r;   rT   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)rf   )rr   rs   template_idrB   ri   r   r  r   )rU   rt   ru   general_templaterv   s       r'   rs   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)r\   r]   r^   r2  r5   r)   r'   r`   r    s    
r)   r`   )$r\   r]   r^   ra   r1   r  r   rc   r  r  rB   r  re   is_mandatoryr   r  r   job_position_idsr  r   rb   r  r  r   ri   rj   rV   r  r  r   r  r  r(  rs   r`   r   r   s   @r'   r  r  f  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" ""8(.
 
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
    r  r   r  r  r+  N)r\   r]   r^   ra   r   rg   r  rh   question_idr   r  r  r   r   ri   r5   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"                  edd      Z ed	      Zed
        ZdefdZy)RecruitmentSurveyAnswerz!
    RecruitmentSurveyAnswer
    r  r   T)rL   rM   rG   r   )rw  rG   rH   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JSONDecodeErrorrT   s    r'   answerzRecruitmentSurveyAnswer.answer  s6    	::d..//## 	I	s   ! 99rO   c                 L    | j                   j                   d| j                   S )Nr\  )r  r/   r  rT   s    r'   rV   zRecruitmentSurveyAnswer.__str__  s'    ##(()4+>+>*?@@r)   N)r\   r]   r^   ra   r   rg   r8  rh   r  r   r  r1   r  r   r   	JSONFieldr  rV  r   
attachmentr   ri   propertyr  rj   rV   r5   r)   r'   r  r    s     %6$$Y&..IL&V&&..}%	N (f''..~&	O #&""$K!!!Kd$OJ#:VWG A A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 G d d      Zd ZdefdZd Zd Zd Zy)	SkillZonez! "
    Model for talent pool
    rC   
Skill Zoner&  r   r  )rM   rE   Tr   )rG   rH   rL   rM   c                   ,    e Zd Z ed      Z ed      Zy)SkillZone.Metar  zSkill ZonesNr[   r5   r)   r'   r`   r  	  s    .r)   r`   c                 D    t         j                  j                  d|       S )NT)r7  skill_zone_id)SkillZoneCandidateri   r   rT   s    r'   
get_activezSkillZone.get_active  s    !))004t0TTr)   rO   c                     | j                   S rQ   rR   rT   s    r'   rV   zSkillZone.__str__  rW   r)   c                 &    d| j                    d}|S r   rR   r   s     r'   r   zSkillZone.get_avatar  r   r)   c                     | j                   j                         }|dk7  r| dt        d       S | dt        d       S )Nr+   r:   rL  r8  )skillzonecandidate_setr   r1   )rU   r   s     r'   candidate_count_displayz!SkillZone.candidate_count_display  sI    ++113A:WAq011WAq~/00r)   c                 T    t        d      }t        d| j                  i      }| d| S )z]
        This method returns the skill zone URL with the title as a query parameter.
        zskill-zone-viewsearchr  )r   r   rS   )rU   r   query_strings      r'   r  zSkillZone.get_skill_zone_url!  s3     ,- (DJJ!781\N++r)   N)r\   r]   r^   ra   r   rb   rS   rc   r1   rd   rg   r   rh   rN   r   ri   r`   r  rj   rV   r   r  r  r5   r)   r'   r  r    s     FFE"&""-0@SQK"""..y\J $%G/ /U 1,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  r  T)rM   r   rL   rG   r8  ry  rx  Reasonr&  )auto_now_addrv  r+  c           	      >   t         j                  j                  | j                  | j                        j                  | j                        j                         }|r/t        t        d| j                   d| j                   d            t        | -          y )N)r  r  r   z
Candidate z already exists in Skill Zone r8   )r  ri   r   r  r  r  r   r  r
   r1   rr   r   )rU   duplicate_existsrv   s     r'   r   zSkillZoneCandidate.cleanK  s     &&--!..d>P>P .  WW VX 	 ! !2!2 33QRVRdRdQeefg  	r)   rO   c                 H    t        | j                  j                               S rQ   )rj   r  r  rT   s    r'   rV   zSkillZoneCandidate.__str__^  s    4$$22455r)   )r\   r]   r^   ra   r   rg   r  r1   r  r  r8  r  rb   reasonr  added_onr   ri   r   rj   rV   r   r   s   @r'   r  r  *  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rL   r   r      )r  c                       e Zd ZddgZy)CandidateRating.Metaemployee_idr  N)r\   r]   r^   r   r5   r)   r'   r`   r  m  s    (.9r)   r`   rO   c                 R    | j                    d| j                   d| j                   S )Nry  z rating )r  r  r  rT   s    r'   rV   zCandidateRating.__str__p  s+    ""#3t'8'8&9$++OOr)   N)r\   r]   r^   r   rg   r   r  r  r8  r  r  r   r   r  r`   rj   rV   r5   r)   r'   r  r  b  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
    Fr  TrL   rG   N)r\   r]   r^   ra   r   re   candidate_self_trackingshow_overall_ratingrg   r   rh   rN   r5   r)   r'   r  r  t  sI     2f11%@-&--e<"""7fnn4PJr)   r  c                      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
      Z ej&                  d ed            Z ed      ZdefdZd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z" G d d      Z#y)r-  z$
    Interview Scheduling Model
    r8  candidate_interview)rM   r   rL   Interviewerr   zInterview DatezInterview Timer   Tru  FzIs Interview Completedr   rv  rO   c                      | j                    dS )Nz -Interview.r  rT   s    r'   rV   zInterviewSchedule.__str__  s    ##$L11r)   c                      t        dd| i      S )z.
        method for candidate coloumn
        z'cbv/interview/candidate_custom_col.htmlr>   r   r   rT   s    r'   candidate_custom_colz&InterviewSchedule.candidate_custom_col  s     :&
 	
r)   c                      t        dd| i      S )z0
        method for interviewer coloumn
        z)cbv/interview/interviewer_custom_col.htmlr>   r   r   rT   s    r'   interviewer_custom_colz(InterviewSchedule.interviewer_custom_col  s     <&
 	
r)   c                     t        t        dd      }t        | dd      s|| _        |j                  }|j                  | j
                  j                         v rd}d}d| d| d| dS y)	zH
        Custom background color for all rows with hover effect
        r  Nzrgba(255, 166, 0, 0.158)whitezstyle="background-color: z,;" onmouseover="this.style.backgroundColor='z,';" onmouseout="this.style.backgroundColor='z';")r  r   r  useremployee_getr  r   )rU   r  r  colorhoverings        r'   custom_colorzInterviewSchedule.custom_color  s     .)T:tY-"DL|| 0 0 4 4 66.EH ,E7 3==EJ G<<A7$H	 7r)   c                     | j                   j                         }dj                  |D cg c]  }t        |       c}      }|S c c}w )z,
        interviewer in detail view
        rx  )r  r   r=   rj   r   s       r'   interviewer_detailz$InterviewSchedule.interviewer_detail  sB     $$((*	 $		*SX3x=*S T$$ +TrH  c                 `    | j                   j                   d| j                   j                   S )z1
        Return subtitle for detail view
        z / )r  r  r   rT   s    r'   detail_subtitlez!InterviewSchedule.detail_subtitle  s1    
   //0D4E4E4U4U3VW	
r)   c                 H    | j                   r| j                   S t        d      S )z!
        get description
        None)rd   r1   rT   s    r'   get_descriptionz!InterviewSchedule.get_description  s#     ###V9r)   c                     t        j                  t        j                  rt        j
                  nd      }t        d| |d      S )z+
        method for status coloumn
        N)r  z$cbv/interview/status_custom_col.htmlr  r   )r   r  r   USE_TZr   utcr    r  s     r'   status_custom_colz#InterviewSchedule.status_custom_col  s6     llhoohll4H7!%c2
 	
r)   c                      t        dd| i      S )z,
        method for actions coloumn
        z$cbv/interview/interview_actions.htmlr>   r   r   rT   s    r'   custom_action_colz#InterviewSchedule.custom_action_col  s     7&
 	
r)   c                 8    t        dd| j                  i      }|S )z!
        for detail view
        zinterview-detail-viewr   r   r   r   s     r'   detail_viewzInterviewSchedule.detail_view  s    
 -tTWWoF
r)   c                      t        dd| i      S )z%
        detail view actions
        z&cbv/interview/detail_view_actions.htmlr>   r   r   rT   s    r'   detail_view_actionsz%InterviewSchedule.detail_view_actions  s     9&
 	
r)   c                   ,    e Zd Z ed      Z ed      Zy)InterviewSchedule.MetazSchedule InterviewzSchedule InterviewsNr[   r5   r)   r'   r`   r    s    -. 56r)   r`   N)$r\   r]   r^   ra   r   rg   r8  r1   rh   r  r  r   r  r  r.  	TimeFieldr/  rc   rd   re   r0  r   ri   rj   rV   r  r  r  r  r  r  r  r  r
  r  r`   r5   r)   r'   r-  r-  ~  s    %6$${^*..	L )&((-@PQK%V%%15E3FGN%V%%15E3FGN"&""}%K $##A&>$?I $$NOG2 2

*%



7 7r)   r-  c                       e Zd Z ej                  eeg      Z ej                  e	ej                  d      Z ej                  d      Zd Zy)Resumer  r  r  Fr  c                 8    | j                    d| j                   S )Nz
 - Resume )r  r   rT   s    r'   rV   zResume.__str__  s    %%&j	::r)   N)r\   r]   r^   r   rV  r   r3   r  rg   r   rh   r  re   is_candidaterV   r5   r)   r'   r  r    sW    6
D 'V&&v~~HN '6&&u5L;r)   r  ))	requested	Requested)approvedApproved)ro  rp  ))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)CandidateDocumentRequestrm   rn   r  )r(  rE   T)rH   rG   r  rH   rG   rE   +employee_id__employee_work_info__company_idr+  c                     | j                   S rQ   rR   rT   s    r'   rV   z CandidateDocumentRequest.__str__-  rW   r)   N)r\   r]   r^   r   rb   rS   r  r8  r  FORMATSformatr  max_sizerc   rd   r   ri   rV   r5   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                  ed      Z ej                  edd	
      Z ej"                  ddd      Zd Z fdZ xZS )CandidateDocument   rn   r8  )rL   rM   Tr  rv  r  r  )r(  rE   rI   r  r*  c                 8    | j                    d| j                   S )Nry  )r  rS   rT   s    r'   rV   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   rS   z#Title must be at least 3 charactersi   documentzFile size exceeds the limitr8   r+   r  zPlease upload {} file only.)rr   r   r6  r	  rS   r
   r1   document_request_idr.  r/  sizer/   r;   r0   )rU   rt   ru   r  r.  r/  r2   rv   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)   )r\   r]   r^   r   rb   rS   rg   r8  r  r  r)  r7  rV  r   r6  STATUSstatusrc   reject_reasonrV   r   r   r   s   @r'   r1  r1  1  s    F,E$6$$V^^+L ,&++ FNN  v+DAHVf[QF$F$$4dsKM5 r)   r1  c                   T    e Zd Z ej                  d ed            Z ej                  d ed            Z ej                  d ed            Z	 ej                  dd	      Z
 ej                  eej                  d ed
            Z G d d      Zd Z fdZd Zd Z xZS )LinkedInAccountr2  zApp Namer&  r|  r}  i  z	API TokenTrD   r   rz  c                   ,    e Zd Z ed      Z ed      Zy)LinkedInAccount.Metar   zLinkedIn AccountsNr[   r5   r)   r'   r`   r?  b  s    +, 34r)   r`   c                 ,    t        | j                        S rQ   )rj   usernamerT   s    r'   rV   zLinkedInAccount.__str__f  r  r)   c                 ^   t        |   |i | d}dd| j                   i}t        j                  ||      }|j
                  dk(  rQ|j                         }|d   | j                  k(  st        dt        d      i      |j                         d   | _
        y t        t        d	            )
Nz$https://api.linkedin.com/v2/userinfoAuthorizationzBearer )headersrx  r  zEmail mismatched.subzCheck the credentials)rr   r   	api_tokenrequestsrM  status_coder  r  r
   r1   sub_id)rU   rt   ru   r   rD  responsedatarv   s          r'   r   zLinkedInAccount.cleani  s    t&v&4"gdnn-=$>?<<W53&==?D=DJJ.%w2E0F&GHH"--/%0DK!!$;"<==r)   c                      t        dd| i      S )r   zlinkedin/linkedin_action.htmlr>   r   r   rT   s    r'   action_templatezLinkedInAccount.action_templatex  s     0&
 	
r)   c                 @    d| j                    }t        d| |d      S )z,
        For toggle is_active field
        z!update-isactive-linkedin-account/zis_active_toggle.html)r>   r   r   )rx   r    r   s     r'   is_active_togglez LinkedInAccount.is_active_toggle  s,     2$'';(!%c2
 	
r)   )r\   r]   r^   r   rb   r1   rA  rU  r  rF  rI  rg   r   rh   rN   r`   rV   r   rM  rO  r   r   s   @r'   r=  r=  Y  s    v3Qz]KHF1W:FE   CanMIVT:F"""6>>1Y<J5 5">

r)   r=  )Vra   r  r,   r#   r   r   urllib.parser   uuidr   r  rG  r   django.confr   django.contrib.auth.modelsr	   django.core.exceptionsr
   django.core.files.storager   django.core.validatorsr   r   	django.dbr   django.urlsr   r   django.utilsr  django.utils.htmlr   django.utils.textr   django.utils.translationr   r1   base.horilla_company_managerr   r%  r   r   employee.modelsr   horilla.horilla_middlewaresr   horilla.modelsr   r   horilla_audit.methodsr   horilla_audit.modelsr   r   horilla_views.cbv_methodsr    r(   r3   r6   r@   rB   rl   r   r  rb  r8  rj  r  r}  r  r  r  r  r  r  r  r  r-  Modelr  r9  r-  r)  r1  r=  r5   r)   r'   <module>re     s    	 	 ' "       + 2 5 G  - ' ) % 6 > , $ 6 4 * B 5

"8:4\ 42/*L /*dY, YxYXL YXx8W
. W
.t+2< +2\N N<. .% %6`
 `
FY| Y"Al "AJ., .,b56 56pPl P$Q Q@7 @7F;V\\ ; 
	| % %P0
l 0
r)   