Skip to content

Commit

Permalink
apply: skip create seeker steps when job_seeker GET param is filled
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenKorr committed Oct 4, 2024
1 parent 9b590f6 commit 96a8940
Show file tree
Hide file tree
Showing 2 changed files with 475 additions and 1 deletion.
32 changes: 31 additions & 1 deletion itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,37 @@ def get(self, request, *args, **kwargs):
else:
self.apply_session.init({"selected_jobs": [job_description.pk]})

# Go directly to step ApplicationJobsView if we're carrying the job seeker public id with us.
if job_seeker_public_id := request.GET.get("job_seeker"):
job_description_id = request.GET.get("job_description_id", None)
default_url = reverse(
"apply:start",
kwargs={"company_pk": self.company.pk},
) + (f"?job_description_id={job_description_id}" if job_description_id else "")

try:
job_seeker = (
User.objects.filter(kind=UserKind.JOB_SEEKER, public_id=job_seeker_public_id)
.select_related("jobseeker_profile")
.first()
)
except (User.DoesNotExist, ValueError, ValidationError):
return HttpResponseRedirect(default_url)
if (
self.request.user.is_authenticated
and job_seeker
and self.request.user.can_view_personal_information(job_seeker)
):
return HttpResponseRedirect(
reverse(
"apply:application_jobs",
kwargs={"company_pk": self.company.pk, "job_seeker_public_id": job_seeker.public_id},
)
+ (f"?job_description_id={job_description_id}" if job_description_id else "")
)
else:
return HttpResponseRedirect(default_url)

# Warn message if prescriber's authorization is pending
if (
request.user.is_prescriber
Expand Down Expand Up @@ -902,7 +933,6 @@ class ApplicationJobsView(ApplicationBaseView):

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

self.form = None

def get_initial(self):
Expand Down
Loading

0 comments on commit 96a8940

Please sign in to comment.