1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-28 01:12:22 +02:00

Problems can be accepted or rejected. Draw can go to the end

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-03-25 06:21:39 +01:00
parent e90005b192
commit cebe977d49
4 changed files with 282 additions and 26 deletions

View File

@ -36,12 +36,12 @@ class Draw(models.Model):
return 'DICE_SELECT_POULES'
elif self.current_round.current_pool.current_team is None:
return 'DICE_ORDER_POULE'
elif self.current_round.current_pool.current_team.accepted is not None:
return 'DRAW_ENDED'
elif self.current_round.current_pool.current_team.purposed is None:
return 'WAITING_DRAW_PROBLEM'
elif self.current_round.current_pool.current_team.accepted is None:
return 'WAITING_CHOOSE_PROBLEM'
else:
return 'DRAW_ENDED'
return 'WAITING_CHOOSE_PROBLEM'
@property
def information(self):
@ -85,9 +85,11 @@ class Draw(models.Model):
else:
s += "Elle peut décider d'accepter ou de refuser ce problème. "
if len(td.rejected) >= settings.PROBLEM_COUNT - 5:
s += "Refuser ce problème ajoutera une nouvelle pénalité de 0.5 sur le coefficient de l'oral de læ défenseurse."
s += "Refuser ce problème ajoutera une nouvelle pénalité de 0.5 sur le coefficient de l'oral de læ défenseurse."
else:
s += f"Il reste {settings.PROBLEM_COUNT - 5 - len(td.rejected)} refus sans pénalité."
case 'DRAW_ENDED':
s += "Le tirage au sort est terminé. Les solutions des autres équipes peuvent être trouvées dans l'onglet « Ma participation »."
s += "<br><br>" if s else ""
s += """Pour plus de détails sur le déroulement du tirage au sort,
@ -131,6 +133,10 @@ class Round(models.Model):
def team_draws(self):
return self.teamdraw_set.order_by('pool__letter', 'passage_index').all()
async def next_pool(self):
pool = await sync_to_async(lambda: self.current_pool)()
return await self.pool_set.aget(letter=pool.letter + 1)
def __str__(self):
return self.get_number_display()
@ -178,6 +184,16 @@ class Pool(models.Model):
async def atrigrams(self):
return await sync_to_async(lambda: self.trigrams)()
async def next_td(self):
td = await sync_to_async(lambda: self.current_team)()
current_index = (td.choose_index + 1) % self.size
td = await self.teamdraw_set.aget(choose_index=current_index)
while td.accepted:
current_index += 1
current_index %= self.size
td = await self.teamdraw_set.aget(choose_index=current_index)
return td
def __str__(self):
return f"{self.get_letter_display()}{self.round.number}"
@ -251,8 +267,9 @@ class TeamDraw(models.Model):
verbose_name=_('rejected problems'),
)
def current(self):
return TeamDraw.objects.get(participation=self.participation, round=self.round.draw.current_round)
@property
def penalty(self):
return max(0, 0.5 * (len(self.rejected) - (settings.PROBLEM_COUNT - 5)))
class Meta:
verbose_name = _('team draw')