From 4dd3c105fe1ba23f357cc87fbbba27c2db773d5a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 Jan 2021 14:30:00 +0100 Subject: [PATCH] Only consider a participant as a child if it is not 18 on the beginning of the tournament --- apps/registration/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/registration/models.py b/apps/registration/models.py index 3e12fce..3a603f8 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -159,7 +159,13 @@ class ParticipantRegistration(Registration): @property def under_18(self): - return (timezone.now().date() - self.birth_date).days < 18 * 365.24 + important_date = timezone.now().date() + if self.team and self.team.participation.tournament: + important_date = self.team.participation.tournament.date_start + if self.team.participation.final: + from participation.models import Tournament + important_date = Tournament.final_tournament().date_start + return (important_date - self.birth_date).days < 18 * 365.24 @property def type(self): # pragma: no cover