From cdc8b4ba59ec27652c0943b9a809f4013a04fca0 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 17 Oct 2024 16:35:02 +0530 Subject: [PATCH] [UPDT] RECRUITMENT: Updated recruitment with the 2 new stages for newly created recruitment for candidates from application and direct creation --- recruitment/forms.py | 1 + recruitment/models.py | 10 +++++++++- recruitment/views.py | 4 ++-- recruitment/views/surveys.py | 4 ++-- recruitment/views/views.py | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/recruitment/forms.py b/recruitment/forms.py index 77dde09e1..b90937206 100644 --- a/recruitment/forms.py +++ b/recruitment/forms.py @@ -352,6 +352,7 @@ class CandidateCreationForm(ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + self.fields["source"].initial = "software" self.fields["profile"].widget.attrs["accept"] = ".jpg, .jpeg, .png" self.fields["profile"].required = False self.fields["resume"].widget.attrs["accept"] = ".pdf" diff --git a/recruitment/models.py b/recruitment/models.py index 73c0385a4..ca275c02d 100644 --- a/recruitment/models.py +++ b/recruitment/models.py @@ -251,8 +251,15 @@ def create_initial_stage(sender, instance, created, **kwargs): This is post save method, used to create initial stage for the recruitment """ if created: + applied_stage = Stage() + applied_stage.sequence = 0 + applied_stage.recruitment_id = instance + applied_stage.stage = "Applied" + applied_stage.stage_type = "applied" + applied_stage.save() + initial_stage = Stage() - initial_stage.sequence = 0 + initial_stage.sequence = 1 initial_stage.recruitment_id = instance initial_stage.stage = "Initial" initial_stage.stage_type = "initial" @@ -266,6 +273,7 @@ class Stage(HorillaModel): stage_types = [ ("initial", _("Initial")), + ("applied", _("Applied")), ("test", _("Test")), ("interview", _("Interview")), ("cancelled", _("Cancelled")), diff --git a/recruitment/views.py b/recruitment/views.py index ad5c692e2..8cce6c016 100644 --- a/recruitment/views.py +++ b/recruitment/views.py @@ -1227,8 +1227,8 @@ def application_form(request): candidate_obj = form.save(commit=False) recruitment_obj = candidate_obj.recruitment_id stages = recruitment_obj.stage_set.all() - if stages.filter(stage_type="initial").exists(): - candidate_obj.stage_id = stages.filter(stage_type="initial").first() + if stages.filter(stage_type="applied").exists(): + candidate_obj.stage_id = stages.filter(stage_type="applied").first() else: candidate_obj.stage_id = stages.order_by("sequence").first() candidate_obj.save() diff --git a/recruitment/views/surveys.py b/recruitment/views/surveys.py index 1514e2bed..27a8f2971 100644 --- a/recruitment/views/surveys.py +++ b/recruitment/views/surveys.py @@ -358,8 +358,8 @@ def application_form(request): candidate_obj = form.save(commit=False) recruitment_obj = candidate_obj.recruitment_id stages = recruitment_obj.stage_set.all() - if stages.filter(stage_type="initial").exists(): - candidate_obj.stage_id = stages.filter(stage_type="initial").first() + if stages.filter(stage_type="applied").exists(): + candidate_obj.stage_id = stages.filter(stage_type="applied").first() else: candidate_obj.stage_id = stages.order_by("sequence").first() messages.success(request, _("Application saved.")) diff --git a/recruitment/views/views.py b/recruitment/views/views.py index 1f32ecc80..17f2e2af3 100644 --- a/recruitment/views/views.py +++ b/recruitment/views/views.py @@ -1272,6 +1272,7 @@ def candidate(request): if form.is_valid(): candidate_obj = form.save(commit=False) candidate_obj.start_onboard = False + candidate_obj.source = "software" if candidate_obj.stage_id is None: candidate_obj.stage_id = Stage.objects.filter( recruitment_id=candidate_obj.recruitment_id, stage_type="initial"