From d3c6cecf515e680414bf35ba2175ad6981b1e243 Mon Sep 17 00:00:00 2001 From: Antoine LAURENT Date: Thu, 9 Jan 2025 22:54:26 +0100 Subject: [PATCH] www: Fix displaying an accepted geiq job application without diagnosis --- itou/www/apply/views/process_views.py | 5 +++-- tests/www/apply/test_geiq.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/itou/www/apply/views/process_views.py b/itou/www/apply/views/process_views.py index a9c20f3e70..ed62916978 100644 --- a/itou/www/apply/views/process_views.py +++ b/itou/www/apply/views/process_views.py @@ -72,8 +72,9 @@ def check_waiting_period(job_application): def _get_geiq_eligibility_diagnosis(job_application, only_prescriber): # Return the job_application diagnosis if it's accepted if job_application.state.is_accepted: - # but not if the viewer is a prescriber and the diangosis was made by the company - if only_prescriber and job_application.geiq_eligibility_diagnosis.author_geiq: + # or None if the viewer is a prescriber and the diangosis was made by the company + # NB. the job application may not have a geiq diagnosis + if only_prescriber and getattr(job_application.geiq_eligibility_diagnosis, "author_geiq", None): return None return job_application.geiq_eligibility_diagnosis return GEIQEligibilityDiagnosis.objects.diagnoses_for( diff --git a/tests/www/apply/test_geiq.py b/tests/www/apply/test_geiq.py index cb64b61315..71c2599905 100644 --- a/tests/www/apply/test_geiq.py +++ b/tests/www/apply/test_geiq.py @@ -229,6 +229,16 @@ def test_with_expired_diagnosis_no_allowance(self, client): assertNotContains(response, self.EXPIRED_DIAGNOSIS_EXPLANATION) assertNotContains(response, self.CONFIRMATION_MODAL) + def test_accepted_without_diagnosis(self, client): + job_application = JobApplicationFactory( + state=JobApplicationState.ACCEPTED, + to_company__kind=CompanyKind.GEIQ, + eligibility_diagnosis=None, + ) + + response = self.get_response(client, job_application, job_application.sender) + assert response.status_code == 200 + def test_get_geiq_eligibility_diagnosis(subtests): expired_prescriber_diagnosis = GEIQEligibilityDiagnosisFactory(