1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 01:58:23 +02:00

First ETEAM adjustments

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-06-07 14:18:25 +02:00
parent 872009894d
commit 08ad4f3888
6 changed files with 216 additions and 172 deletions

View File

@ -1,6 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
import math
from datetime import date, timedelta
import os
@ -37,12 +37,13 @@ class Team(models.Model):
)
trigram = models.CharField(
max_length=3,
verbose_name=_("trigram"),
help_text=_("The trigram must be composed of three uppercase letters."),
max_length=settings.TEAM_CODE_LENGTH,
verbose_name=_("code"),
help_text=format_lazy(_("The code must be composed of {nb_letters} uppercase letters."),
nb_letters=settings.TEAM_CODE_LENGTH),
unique=True,
validators=[
RegexValidator(r"^[A-Z]{3}$"),
RegexValidator(fr"^[A-Z]{{f'{settings.TEAM_CODE_LENGTH}'}}$"),
RegexValidator(fr"^(?!{'|'.join(f'{t}$' for t in settings.FORBIDDEN_TRIGRAMS)})",
message=_("This trigram is forbidden.")),
],
@ -940,7 +941,7 @@ class Pool(models.Model):
choices=[
(1, format_lazy(_("Round {round}"), round=1)),
(2, format_lazy(_("Round {round}"), round=2)),
]
] + ([] if settings.NB_ROUNDS == 2 else [(3, format_lazy(_("Round {round}"), round=3))]),
)
letter = models.PositiveSmallIntegerField(
@ -1010,12 +1011,16 @@ class Pool(models.Model):
def solutions(self):
return [passage.defended_solution for passage in self.passages.all()]
@property
def coeff(self):
return 1 if self.round <= 2 else math.pi - 2
def average(self, participation):
return sum(passage.average(participation) for passage in self.passages.all()) \
return self.coeff * sum(passage.average(participation) for passage in self.passages.all()) \
+ sum(tweak.diff for tweak in participation.tweaks.filter(pool=self).all())
async def aaverage(self, participation):
return sum([passage.average(participation) async for passage in self.passages.all()]) \
return self.coeff * sum([passage.average(participation) async for passage in self.passages.all()]) \
+ sum([tweak.diff async for tweak in participation.tweaks.filter(pool=self).all()])
def get_absolute_url(self):