diff --git a/itou/job_applications/models.py b/itou/job_applications/models.py index 12d27d237f3..ff4579f2b11 100644 --- a/itou/job_applications/models.py +++ b/itou/job_applications/models.py @@ -938,6 +938,18 @@ def get_sender_kind_display(self): else: return SenderKind(self.sender_kind).label + @property + def sender_left_org(self): + if self.sender_prescriber_organization_id: + return not ( + self.sender.prescribermembership_set.active() + .filter(organization_id=self.sender_prescriber_organization_id) + .exists() + ) + if self.sender_company_id: + return not (self.sender.companymembership_set.active().filter(company_id=self.sender_company_id).exists()) + return False + @property def is_in_transferable_state(self): return self.state in JobApplicationWorkflow.CAN_BE_TRANSFERRED_STATES diff --git a/itou/templates/apply/includes/job_application_sender_info.html b/itou/templates/apply/includes/job_application_sender_info.html index 4b0e570cbbd..1ca020f7550 100644 --- a/itou/templates/apply/includes/job_application_sender_info.html +++ b/itou/templates/apply/includes/job_application_sender_info.html @@ -1,6 +1,21 @@ {% load format_filters %} {% load matomo %} +{% if job_application.sender_left_org %} +
L’émetteur de cette candidature ne fait plus partie de l’organisation émettrice
+