From 6046f3c63bda5ef2dff46385d5ff5369f75f7056 Mon Sep 17 00:00:00 2001 From: Antoine LAURENT Date: Mon, 14 Oct 2024 11:51:42 +0200 Subject: [PATCH] apply: Mask sender email when he left his organization --- itou/job_applications/models.py | 13 +++++ .../includes/job_application_sender_info.html | 17 ++++++ tests/job_applications/test_models.py | 58 +++++++++++++++++++ .../www/apply/__snapshots__/test_process.ambr | 48 ++++++++++++++- tests/www/apply/test_process.py | 46 +++++++++++++++ 5 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 tests/job_applications/test_models.py diff --git a/itou/job_applications/models.py b/itou/job_applications/models.py index 12d27d237f3..9f36f9305f8 100644 --- a/itou/job_applications/models.py +++ b/itou/job_applications/models.py @@ -1,4 +1,5 @@ import uuid +from functools import cached_property from django.conf import settings from django.core.exceptions import ValidationError @@ -938,6 +939,18 @@ def get_sender_kind_display(self): else: return SenderKind(self.sender_kind).label + @cached_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

+
+
+
+ + +{% endif %}