Skip to content

Commit

Permalink
Reuse GEIQEligibilityDiagnosis.valid_diagnosis_for()
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag committed Sep 18, 2024
1 parent e2627ab commit 54d4103
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions itou/eligibility/models/geiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ def clean(self):

# The following would have been nice in a unique constraint,
# but infortunately functions.Now() is not immutable
if self.job_seeker and (
GEIQEligibilityDiagnosis.objects.valid()
.filter(job_seeker=self.job_seeker)
.filter(models.Q(author_geiq=self.author_geiq) | models.Q(author_prescriber_organization__isnull=False))
.exists()
if (
self.job_seeker
and GEIQEligibilityDiagnosis.objects.valid_diagnoses_for(self.job_seeker, self.author_geiq).exists()
):
raise ValidationError(f"Il existe déjà un diagnostic GEIQ valide pour cet utilisateur : {self.job_seeker}")

Expand Down

0 comments on commit 54d4103

Please sign in to comment.