
    vgK                     4   d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZ  G d de      ZdZ G d	 d
e      Z G d de      Z G d de      Z G d dej                        Z G d d      Z G d de      Z G d de      Z G d de      Zy)zJ
filters.py

This page is used to register filter for recruitment models

    N)forms)	FilterSet)	CandidateInterviewScheduleRecruitmentRecruitmentSurvey	SkillZoneSkillZoneCandidateStageSurveyTemplatec                       e Zd ZdZ ej
                  dd      Z ej                  ej                  j                         d      Z ej
                  dd      Z ej                  d ej                  d	d
i            Z ej                  d ej                  d	d
i            Z ej                  dd ej                  d	d
i            Z ej                  d ej                  d	d
i            Z ej                  dd ej                  d	d
i            Z ej                  dd ej                  d	d
i            Z ej                  d ej                  d	d
i            Z ej                  d ej                  d	d
i            Z ej                  dd ej                  d	d
i            Z ej
                  dd      Z ej4                  ddej6                  j9                               Z ej4                  ddej6                  j9                               Zd Z G d d      Z  fdZ!d Z"d Z# xZ$S ) CandidateFilter}
    Filter set class for Candidate model

    Args:
        FilterSet (class): custom filter set class to apply styling
    name	icontains
field_namelookup_expr)querysetr   pipeline_search)methodr   recruitment_id__start_datetypedateattrsr   widgetrecruitment_id__end_date#candidate_interview__interview_dategter   r   r   probation_endlteschedule_daterecruitment_id__titleonboarding_portalfilter_mail_sentr   r   r   joining_datefilter_joining_setc                     |j                  |      |j                  |      z  |j                  |      z  j                         }|S )zc
        This method is used to include the candidates when they in the recruitment/stages
        )name__icontains)stage_id__stage__icontains)*stage_id__recruitment_id__title__icontainsfilterdistinctselfr   _values       '/var/www/horilla/recruitment/filters.pyr   zCandidateFilter.pipeline_searche   sO    
 OOEO2ooo?@oooOP (*	 	
     c                       e Zd ZdZeZg dZy)CandidateFilter.Meta7
        Meta class to add the additional info
        )"recruitmentrecruitment_idstage_idr%   r    emailmobilecountrystatecityzipgenderstart_onboardhired	convertedcanceled	is_activerecruitment_id__company_idjob_position_idrecruitment_id__closedrecruitment_id__is_activejob_position_id__department_id$recruitment_id__recruitment_managersstage_id__stage_managersstage_id__stage_typer*   %skillzonecandidate_set__skill_zone_id$skillzonecandidate_set__candidate_idportal_sentjoining_set$rejected_candidate__reject_reason_idoffer_letter_statuscandidate_rating__rating candidate_interview__employee_idN)__name__
__module____qualname____doc__r   modelfields r8   r7   Metar:   p   s    	 #
r8   rb   c                 8   t        |   |i | d| j                  j                  d   _        | j                  j                  j                         D ]E  }t        j                          | j                  j                  |   j                  j                  d<   G y )NTrJ   id)
super__init__formr`   initialkeysuuiduuid4r   r   )r4   argskwargsfield	__class__s       r7   rf   zCandidateFilter.__init__   s}    $)&)04		%-YY%%**, 	KE<@JJL>DIIU#**006	Kr8   c                 (    |j                  |       S )N)onboarding_portal__isnullr1   r4   r   r   r6   s       r7   r(   z CandidateFilter.filter_mail_sent   s    e)EEr8   c                 (    |j                  |       S )N)joining_date__isnullrr   rs   s       r7   r+   z"CandidateFilter.filter_joining_set   s    Y@@r8   )%r[   r\   r]   r^   django_filters
CharFilterr   ModelMultipleChoiceFilterr   objectsall	candidatecandidate_name
DateFilterr   	DateInput
start_dateend_datescheduled_fromr#   probation_end_tillprobation_end_fromr%   interview_datescheduled_tillr<   BooleanFilterwidgetsBooleanWidgetrU   rV   r   rb   rf   r(   r+   __classcell__)ro   s   @r7   r   r      sy    %>$$KPD888""&&(I
 /^.. kN +**/uff%56J )~((-uff%56H /^..8uff%56N
 .N--"uff%56M 322"uff%56
 322"uff%56
 .N--"uff%56M /^..8uff%56N /^..8uff%56N
 ,.++*K /...&!%%335K
 /...!#%%335K	)
 )
VKFAr8   r   )) r   )falseFalse)trueTruec                   8   e Zd ZdZ ej
                  dd      Z ej
                  dd      Z ej
                  d      Z ej                  d e
j                  d	d
i            Z ej                  d e
j                  d	d
i            Z ej                  dd e
j                  d	d
i            Z ej                  dd e
j                  d	d
i            Z ej
                  d      Z ej"                  ddg      Z G d d      Zd Zd Zd Zy)RecruitmentFilterz
    Filter set class for Recruitment model

    Args:
        FilterSet (class): custom filter set class to apply styling
    titler   r   r   onboarding_searchr   )r   r   r   r   r   r   r   r!   r"   r$   filter_by_namer   )TYes)FNo)choicesc                       e Zd ZdZeZg dZy)RecruitmentFilter.Metar;   )
recruitment_managers
company_idr   is_event_basedr   r   closedrJ   is_publishedrL   N)r[   r\   r]   r^   r   r_   r`   ra   r8   r7   rb   r      s    	 
r8   rb   c                 j   |j                         }|d   }t        |      dkD  rdj                  |dd       nd}|j                  |      |j                  |      z  }|r|r|j                  ||      }n)|r|j                  |	      }n|r|j                  |
      }||z  }|j	                         S )=
        Filter queryset by first name or last name.
        r       Nr   )'open_positions__job_position__icontainstitle__icontains)4recruitment_managers__employee_first_name__icontains3recruitment_managers__employee_last_name__icontains)r   )r   )splitlenjoinr1   r2   )r4   r   r5   r6   parts
first_name	last_namejob_querysets           r7   r   z RecruitmentFilter.filter_by_name   s    
 1X
+.u:>CHHU12Y'r	49 ' 
OOUO34 )EODM ' H EO ' H DM ' H l*  ""r8   c                     |j                  |      |j                  |      z  |j                  |      z  }|j                         S );
        This method is used to search recruitment
        r   )stage_set__stage__icontainscandidate__name__icontainsr0   r3   s       r7   r   z!RecruitmentFilter.pipeline_search  sP    
 OOUO3oo%o@Aooo?@ 	
   ""r8   c                     |j                  |      |j                  |      z  |j                  |      z  }|j                         S )r   r   )(onboarding_stage__stage_title__icontains):candidate__onboarding_stage__candidate_id__name__icontainsr0   r3   s       r7   r   z#RecruitmentFilter.onboarding_search  sU    
 OOUO3oouoMNooKP   	   ""r8   N)r[   r\   r]   r^   rv   rw   r|   search_onboardingdescriptionr}   r   r~   r   r   
start_fromend_tillsearchChoiceFilterrJ   rb   r   r   r   ra   r8   r7   r   r      sE    /^..#4N 211#6 ,.++DK***vv>N(OJ )~((oeooVV<L&MH +**uff%56J
 )~((uff%56H
 '^&&.>?F+++
I
 
&#:	##r8   r   c                   |    e Zd ZdZ ej
                  d      Z ej
                  d      Z G d d      Zd Z	d Z
y	)
StageFilterzy
    Filter set class for Stage model

    Args:
        FilterSet (class): custom filter set class to apply styling
    r   r   r   c                       e Zd ZdZeZg dZy)StageFilter.Metar;   )r=   recruitment_id__job_position_id.recruitment_id__job_position_id__department_idrK   rP   stage_managers
stage_typeN)r[   r\   r]   r^   r   r_   r`   ra   r8   r7   rb   r   *  s    	 
r8   rb   c                 R   |j                         }|d   }t        |      dkD  rdj                  |dd       nd}|j                  |      }|j                  |      }|r|r|j                  ||      }n)|r|j                  |	      }n|r|j                  |
      }||z  |z  }|S )r   r   r   r   Nr    recruitment_id__title__icontainsstage__icontains).stage_managers__employee_first_name__icontains-stage_managers__employee_last_name__icontains)r   )r   )r   r   r   r1   )	r4   r   r5   r6   r   r   r   recruitment_querystage_querysets	            r7   r   zStageFilter.filter_by_name:  s    
 1X
+.u:>CHHU12Y'r	$OOUOS!%@)?I>G ' H ?I ' H >G ' H n,/@@r8   c                     |j                  |      |j                  |      z  |j                  |      z  }|j                         S )r   r   r   r   r0   r3   s       r7   r   zStageFilter.pipeline_searchV  sP    
 OOUO3ooo?@oouoEF 	
   ""r8   N)r[   r\   r]   r^   rv   rw   r   r|   rb   r   r   ra   r8   r7   r   r     sC     '^&&.>?F.^..6GHN
 
 8	#r8   r   c                   x    e Zd ZdZ ej
                  ddd      Z ej
                  ddd      Z G d d	      Zy
)SurveyFilterz
    SurveyFIlter
    r   Optionsoptionsr   labelr   Questionquestionc                       e Zd ZdZeZdZdgZy)SurveyFilter.Meta3
        class Meta for additional options
        __all__sequenceN)r[   r\   r]   r^   r   r_   r`   excludera   r8   r7   rb   r   s  s    	 "
r8   rb   N)	r[   r\   r]   r^   rv   rw   r   r   rb   ra   r8   r7   r   r   b  sK     (n''G )~((H	
 	
r8   r   c                   N    e Zd ZdZ ej
                  ddd      Z G d d      Zy)	SurveyTemplateFilterz
    SurveyTemplateFilter
    r   Titler   r   c                       e Zd ZeZdZy)SurveyTemplateFilter.Metar   N)r[   r\   r]   r   r_   r`   ra   r8   r7   rb   r     s    r8   rb   N)r[   r\   r]   r^   rv   rw   r   rb   ra   r8   r7   r   r     s.     )~((H r8   r   c                       e Zd ZdZg dZy)CandidateReGroupz:
    Class to keep the field name for group by option
    ))r   select)r=   r   )rL   zJob Position)rG   Hired)rA   Country)r>   r   )r*   zDate Joining)r#   zProbation End)rX   zOffer Letter Status)rW   zReject Reason)rS   z
Skill ZoneN)r[   r\   r]   r^   r`   ra   r8   r7   r   r     s    Fr8   r   c                   L    e Zd ZdZ ej
                  dd      Z G d d      Zy)SkillZoneFilterz
    Skillzone Filter
    r   r   r   c                       e Zd ZdZeZg dZy)SkillZoneFilter.Metar   )rJ   rT   4skillzonecandidate_set__candidate_id__recruitment_id5skillzonecandidate_set__candidate_id__job_position_id:skillzonecandidate_set__candidate_id__stage_id__stage_typeN)r[   r\   r]   r^   r	   r_   r`   ra   r8   r7   rb   r     s    	 
r8   rb   N)r[   r\   r]   r^   rv   rw   r   rb   ra   r8   r7   r   r     s'     '^&&'{SF
 
r8   r   c                      e Zd ZdZ ej
                  dd      Z ej                  d ej                  ddi      	      Z
 ej                  d
 ej                  ddi      	      Z ej                  dd ej                  ddi            Z ej                  d ej                  ddi      	      Z ej                  dd ej                  ddi            Z ej                  dd ej                  ddi            Z ej                  d ej                  ddi      	      Z ej                  dd ej                  ddi            Z ej
                  dd      Z ej&                  ddej(                  j+                               Z ej&                  ddej(                  j+                               Z G d d      Zd Zy)SkillZoneCandFilterz$
    Skillzone Candidate FIlter
    candidate_id__namecand_searchr   )candidate__id__recruitment_id__start_dater   r   r   r   'candidate__id__recruitment_id__end_datecandidate__id__joining_dater!   r"   candidate__id__probation_endr$   candidate__id__schedule_date$candidate__id__recruitment_id__titler   r    candidate__id__onboarding_portalr(   r)   r+   c                   $    e Zd ZdZeZg dZddgZy)SkillZoneCandFilter.Metar   )rJ   candidate_idcandidate_id__recruitment_idcandidate_id__stage_idcandidate_id__schedule_datecandidate_id__emailcandidate_id__mobilecandidate_id__countrycandidate_id__statecandidate_id__citycandidate_id__zipcandidate_id__gendercandidate_id__start_onboardcandidate_id__hiredcandidate_id__canceledcandidate_id__is_active(candidate_id__recruitment_id__company_idcandidate_id__job_position_id$candidate_id__recruitment_id__closed'candidate_id__recruitment_id__is_active,candidate_id__job_position_id__department_id2candidate_id__recruitment_id__recruitment_managers&candidate_id__stage_id__stage_managers"candidate_id__stage_id__stage_typecandidate_id__joining_date3candidate_id__skillzonecandidate_set__skill_zone_id2candidate_id__skillzonecandidate_set__candidate_id2candidate_id__rejected_candidate__reject_reason_id!candidate_id__offer_letter_status&candidate_id__candidate_rating__ratingreasonry   N)r[   r\   r]   r^   r
   r_   r`   r   ra   r8   r7   rb   r     s%    	 #
B 
r8   rb   c                 h    |j                  |      |j                  |      z  j                         S )zI
        This method to include candidate when search skill zone
        )candidate_id__name__icontains)skill_zone_id__title__icontainsr0   r3   s       r7   r   zSkillZoneCandFilter.cand_search  s2    
 OO%O@ooeoDE
(*	r8   N)r[   r\   r]   r^   rv   rw   r   r}   r   r~   r   r   r   r#   r   r   r%   r   r<   r   r   r   rU   rV   rb   r   ra   r8   r7   r   r     s    '^&&'F +**>uff%56J )~((<uff%56H /^..0uff%56N
 .N--1uff%56M 3221uff%56
 3221uff%56
 .N--1uff%56M /^..0uff%56N
 ,.++9{K /...5!%%335K
 /...0#%%335K)
 )
Vr8   r   c                       e Zd ZdZ ej
                  dd      Z ej                  dd ej                  ddi	      
      Z
 ej                  dd ej                  ddi	      
      Z G d d      Zy)InterviewFilterr   r   r   r   r   r!   r   r   r   r"   r$   c                       e Zd ZdZeZg dZy)InterviewFilter.Metar;   )r   employee_idr   N)r[   r\   r]   r^   r   r_   r`   ra   r8   r7   rb   r   D  s    	 "$
r8   rb   N)r[   r\   r]   r^   rv   rw   r   r}   r   r~   r   r   rb   ra   r8   r7   r  r  )  s     '^&&'[F /^..#uff%56N /^..#uff%56N*
 *
r8   r  )r^   rj   rv   djangor   base.filtersr   recruitment.modelsr   r   r   r   r	   r
   r   r   r   BOOLEAN_CHOICESr   r   r   r   r   r   r   r  ra   r8   r7   <module>r&     s       "	 	 	IAi IAXm#	 m#`@#) @#F
9 
:>33   (
i 
,m) m`E
i E
r8   