1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:42:22 +00:00

Fix under_18 calculus for students that are born on the February 29th

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-07 16:42:05 +02:00
parent 3045857897
commit 4a094002f0
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -224,7 +224,11 @@ class ParticipantRegistration(Registration):
important_date = localtime(timezone.now()).date()
if self.team and self.team.participation.tournament:
important_date = self.team.participation.tournament.date_start
over_18_on = self.birth_date.replace(year=self.birth_date.year + 18)
birth_date = self.birth_date
if self.birth_date.month == 2 and self.birth_date.day == 29:
# If the birth date is the 29th of February, we consider it as the 1st of March
birth_date = important_date.replace(month=3, day=1)
over_18_on = birth_date.replace(year=birth_date.year + 18)
return important_date < over_18_on
@property
@ -233,7 +237,10 @@ class ParticipantRegistration(Registration):
return False # In normal case
from participation.models import Tournament
important_date = Tournament.final_tournament().date_start
over_18_on = self.birth_date.replace(year=self.birth_date.year + 18)
if self.birth_date.month == 2 and self.birth_date.day == 29:
# If the birth date is the 29th of February, we consider it as the 1st of March
birth_date = important_date.replace(month=3, day=1)
over_18_on = birth_date.replace(year=birth_date.year + 18)
return important_date < over_18_on
@property