mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 04:22:14 +01:00 
			
		
		
		
	First ETEAM adjustments
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -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):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user