Skip to content

Commit

Permalink
Set select_job back_url to accessible views
Browse files Browse the repository at this point in the history
- Job seeker: must pass through the check_job_seeker_infos view, so
  their profile is complete. Direct them back to the company.
- Employer/prescriber who cannot edit personal information: return to
  the company.
- Employer/prescriber who can edit personal information: direct them to
  the update_job_seeker_info process
  • Loading branch information
francoisfreitag committed Apr 3, 2024
1 parent 5b481b7 commit a7c06ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 15 additions & 9 deletions itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from itou.utils.apis.exceptions import AddressLookupError
from itou.utils.emails import redact_email_address, send_email_messages
from itou.utils.session import SessionNamespace, SessionNamespaceRequiredMixin
from itou.utils.urls import add_url_params
from itou.www.apply.forms import (
ApplicationJobsForm,
CheckJobSeekerInfoForm,
Expand Down Expand Up @@ -857,15 +858,20 @@ def get_context_data(self, **kwargs):
}

def get_back_url(self):
if self.get_previous_applications_queryset().exists():
return reverse(
"apply:step_check_prev_applications",
kwargs={"company_pk": self.company.pk, "job_seeker_pk": self.job_seeker.pk},
)

return reverse(
"apply:step_check_job_seeker_info",
kwargs={"company_pk": self.company.pk, "job_seeker_pk": self.job_seeker.pk},
if self.request.user.is_job_seeker or not self.request.user.can_edit_personal_information(self.job_seeker):
# Job seekers may come from a job description card. Directing them
# back to the company is good enough: it’s easy to find job
# descriptions from there.
return reverse("companies_views:card", kwargs={"siae_id": self.company.pk})
return add_url_params(
reverse(
"apply:update_job_seeker_step_1",
kwargs={
"company_pk": self.company.pk,
"job_seeker_pk": self.job_seeker.pk,
},
),
{"back_url": self.request.get_full_path()},
)


Expand Down
5 changes: 5 additions & 0 deletions tests/www/apply/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,11 @@ def test_apply_as_authorized_prescriber(self):

response = self.client.get(next_url)
assert response.status_code == 200
back_url = reverse(
"apply:update_job_seeker_step_1",
kwargs={"company_pk": company.pk, "job_seeker_pk": new_job_seeker.pk},
)
assertContains(response, back_url)

response = self.client.post(next_url, data={"selected_jobs": [company.job_description_through.first().pk]})
assert response.status_code == 302
Expand Down

0 comments on commit a7c06ff

Please sign in to comment.