You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
padelclub_backend/tournaments/models/round.py

34 lines
1.3 KiB

from django.db import models
from . import Tournament, FederalMatchCategory
import uuid
class Round(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)
index = models.IntegerField(null=True, blank=True)
loser = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True)
def __str__(self):
return f"{self.tournament.name} - {self.name()}"
# def stage_call(self):
# stage_call = StageCall(f"1/{self.index}")
# for match in self.match_set.all():
# names = map(lambda ts: ts.player_names(), match.teamstate_set.all())
# if names:
# team_call = TeamCall(names, match.formatted_start_date)
# stage_call.add_team(team_call)
# return stage_call
def name(self):
if self.index == 0:
return "Finale"
elif self.index == 1:
return "Demi-Finales"
elif self.index == 2:
return "Quarts de finale"
else:
squared = 2 ** self.index
return f"{squared}ème"