Skip to content

Commit

Permalink
job_seekers_views: use a list for exected session kinds
Browse files Browse the repository at this point in the history
The get or create job seeker steps (ie. CheckNIR* and SearchByEmail* views)
need to accept two session kinds: sender and hire.
  • Loading branch information
EwenKorr committed Jan 10, 2025
1 parent 83c13cb commit e4f592e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions itou/www/job_seekers_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_queryset(self):


class JobSeekerBaseView(TemplateView):
EXPECTED_SESSION_KIND = None
EXPECTED_SESSION_KINDS = None

def __init__(self):
super().__init__()
Expand All @@ -203,7 +203,7 @@ def setup(self, request, *args, session_uuid, hire_process=False, **kwargs):
# Ensure we are performing the action (update, create…) the session was created for.
if (
session_kind := self.job_seeker_session.get("config").get("session_kind")
) and session_kind != self.EXPECTED_SESSION_KIND:
) and session_kind not in self.EXPECTED_SESSION_KINDS:
raise Http404
self.is_gps = "gps" in request.GET and request.GET["gps"] == "true"
if company_pk := self.job_seeker_session.get("apply", {}).get("company_pk"):
Expand Down Expand Up @@ -276,7 +276,7 @@ def dispatch(self, request, *args, **kwargs):

class CheckNIRForJobSeekerView(JobSeekerBaseView):
template_name = "job_seekers_views/step_check_job_seeker_nir.html"
EXPECTED_SESSION_KIND = "job-seeker-get-or-create-job-seeker"
EXPECTED_SESSION_KINDS = ["job-seeker-get-or-create-job_seeker"]

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -336,7 +336,7 @@ def get_context_data(self, **kwargs):

class CheckNIRForSenderView(JobSeekerForSenderBaseView):
template_name = "job_seekers_views/step_check_job_seeker_nir.html"
EXPECTED_SESSION_KIND = "job-seeker-get-or-create-sender"
EXPECTED_SESSION_KINDS = ["job-seeker-get-or-create-sender", "job-seeker-get-or-create-hire"]

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -398,6 +398,7 @@ def get_context_data(self, **kwargs):

class SearchByEmailForSenderView(JobSeekerForSenderBaseView):
template_name = "job_seekers_views/step_search_job_seeker_by_email.html"
EXPECTED_SESSION_KINDS = ["job-seeker-get-or-create-sender", "job-seeker-get-or-create-hire"]

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -496,6 +497,7 @@ def get_context_data(self, **kwargs):

class CreateJobSeekerForSenderBaseView(JobSeekerForSenderBaseView):
required_session_namespaces = ["job_seeker_session"]
EXPECTED_SESSION_KINDS = ["job-seeker-get-or-create-sender", "job-seeker-get-or-create-hire"]

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -803,7 +805,7 @@ def get(self, request, *args, **kwargs):


class UpdateJobSeekerBaseView(JobSeekerBaseView):
EXPECTED_SESSION_KIND = "job-seeker-update"
EXPECTED_SESSION_KINDS = ["job-seeker-update"]

def __init__(self):
super().__init__()
Expand Down

0 comments on commit e4f592e

Please sign in to comment.