From a1c47c56e787daa2b7fb5d5e003233b58961a831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=CC=81o=20S?= Date: Mon, 22 Apr 2024 13:45:57 +0200 Subject: [PATCH] fix(apply): hide sender email when current user is a job seeker --- .../includes/job_application_sender_info.html | 26 +++++++------ tests/www/apply/test_process.py | 38 +++++++++++++++++++ 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/itou/templates/apply/includes/job_application_sender_info.html b/itou/templates/apply/includes/job_application_sender_info.html index 6ea2ec2a04..6ad067d701 100644 --- a/itou/templates/apply/includes/job_application_sender_info.html +++ b/itou/templates/apply/includes/job_application_sender_info.html @@ -12,17 +12,21 @@
  • Adresse e-mail - {{ job_application.sender.email }} - + {% if request.user.is_job_seeker and job_application.sender_kind != SenderKind.JOB_SEEKER %} + Non communiquée + {% else %} + {{ job_application.sender.email }} + + {% endif %}
  • {% if job_application.sender_prescriber_organization %} diff --git a/tests/www/apply/test_process.py b/tests/www/apply/test_process.py index d4c9abcd90..bd7d67a2d7 100644 --- a/tests/www/apply/test_process.py +++ b/tests/www/apply/test_process.py @@ -2741,6 +2741,44 @@ def test_details_for_jobseeker_geiq_with_prior_actions(client): assertNotContains(response, delete_button) +def test_details_sender_email_display_for_job_seeker(client): + SENDER_EMAIL_HIDDEN = "Adresse e-mailNon communiquée" + + # Email hidden for prescriber + job_application = JobApplicationFactory(sent_by_authorized_prescriber_organisation=True) + job_seeker = job_application.job_seeker + + client.force_login(job_seeker) + + url = reverse("apply:details_for_jobseeker", kwargs={"job_application_id": job_application.pk}) + response = client.get(url) + assertNotContains( + response, f"Adresse e-mail{job_application.sender.email}", html=True + ) + assertContains(response, SENDER_EMAIL_HIDDEN, html=True) + + # Email hidden for employer + employer = job_application.to_company.members.first() + job_application.sender = employer + job_application.sender_kind = job_applications_enums.SenderKind.EMPLOYER + job_application.save(update_fields=["sender", "sender_kind"]) + response = client.get(url) + assertNotContains( + response, f"Adresse e-mail{job_application.sender.email}", html=True + ) + assertContains(response, SENDER_EMAIL_HIDDEN, html=True) + + # Email shown for job seeker + job_application.sender = job_seeker + job_application.sender_kind = job_applications_enums.SenderKind.JOB_SEEKER + job_application.save(update_fields=["sender", "sender_kind"]) + response = client.get(url) + assertContains( + response, f"Adresse e-mail{job_application.sender.email}", html=True + ) + assertNotContains(response, SENDER_EMAIL_HIDDEN, html=True) + + def test_accept_button(client): job_application = JobApplicationFactory( state=job_applications_enums.JobApplicationState.PROCESSING,