Skip to content

Commit

Permalink
fix(apply): hide sender email when current user is a job seeker
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-naeka committed Apr 25, 2024
1 parent 4b34608 commit 5ee2233
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
26 changes: 15 additions & 11 deletions itou/templates/apply/includes/job_application_sender_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
</li>
<li>
<small>Adresse e-mail</small>
<strong>{{ job_application.sender.email }}</strong>
<button class="btn-link"
data-bs-toggle="tooltip"
data-bs-placement="top"
data-bs-trigger="manual"
data-bs-title="Copié!"
data-it-clipboard-button="copy"
data-it-copy-to-clipboard="{{ job_application.sender.email }}"
{% matomo_event "candidature" "clic" "copied_sender_email" %}>
<i class="ri-file-copy-line"></i>
</button>
{% if request.user.is_job_seeker and job_application.sender_kind != SenderKind.JOB_SEEKER %}
<strong>Non communiquée</strong>
{% else %}
<strong>{{ job_application.sender.email }}</strong>
<button class="btn-link"
data-bs-toggle="tooltip"
data-bs-placement="top"
data-bs-trigger="manual"
data-bs-title="Copié!"
data-it-clipboard-button="copy"
data-it-copy-to-clipboard="{{ job_application.sender.email }}"
{% matomo_event "candidature" "clic" "copied_sender_email" %}>
<i class="ri-file-copy-line"></i>
</button>
{% endif %}
</li>

{% if job_application.sender_prescriber_organization %}
Expand Down
38 changes: 38 additions & 0 deletions tests/www/apply/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<small>Adresse e-mail</small><strong>Non communiquée</strong>"

# 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"<small>Adresse e-mail</small><strong>{job_application.sender.email}</strong>", 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"<small>Adresse e-mail</small><strong>{job_application.sender.email}</strong>", 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"<small>Adresse e-mail</small><strong>{job_application.sender.email}</strong>", html=True
)
assertNotContains(response, SENDER_EMAIL_HIDDEN, html=True)


def test_accept_button(client):
job_application = JobApplicationFactory(
state=job_applications_enums.JobApplicationState.PROCESSING,
Expand Down

0 comments on commit 5ee2233

Please sign in to comment.