|
|
|
@ -281,9 +281,8 @@ class Match(models.Model): |
|
|
|
_minutes = int((_seconds % 3600) / 60) |
|
|
|
_minutes = int((_seconds % 3600) / 60) |
|
|
|
return f"{_hours:02d}h{_minutes:02d}min" |
|
|
|
return f"{_hours:02d}h{_minutes:02d}min" |
|
|
|
|
|
|
|
|
|
|
|
def seconds(self): |
|
|
|
# def seconds(self): |
|
|
|
return (timezone.now() - self.date).total_seconds() |
|
|
|
# return (timezone.now() - self.start_date).total_seconds() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def live_match(self): |
|
|
|
def live_match(self): |
|
|
|
title = f"{self.index}" |
|
|
|
title = f"{self.index}" |
|
|
|
@ -293,9 +292,18 @@ class Match(models.Model): |
|
|
|
livematch = LiveMatch(title, date, duration) |
|
|
|
livematch = LiveMatch(title, date, duration) |
|
|
|
|
|
|
|
|
|
|
|
for team_state in self.team_states: |
|
|
|
for team_state in self.team_states: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image = team_state.team_registration.logo |
|
|
|
|
|
|
|
names = team_state.team_names() |
|
|
|
|
|
|
|
scores = team_state.score |
|
|
|
|
|
|
|
weight = team_state.weight |
|
|
|
|
|
|
|
is_winner = False |
|
|
|
|
|
|
|
team = Team(image, names, scores, weight, is_winner) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
# def __init__(self, names, date, weight, stage, image): |
|
|
|
# def __init__(self, image, names, scores, weight, is_winner): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -373,6 +381,7 @@ class TeamState(models.Model): |
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) |
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) |
|
|
|
match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name="team_states") |
|
|
|
match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name="team_states") |
|
|
|
player_registrations = models.ManyToManyField(PlayerRegistration, blank=True) |
|
|
|
player_registrations = models.ManyToManyField(PlayerRegistration, blank=True) |
|
|
|
|
|
|
|
team_registration = models.ForeignKey(Match, on_delete=models.CASCADE) |
|
|
|
score = models.CharField(max_length=50, null=True, blank=True) |
|
|
|
score = models.CharField(max_length=50, null=True, blank=True) |
|
|
|
walk_out = models.IntegerField(null=True, blank=True) #id, int of the walked_out team |
|
|
|
walk_out = models.IntegerField(null=True, blank=True) #id, int of the walked_out team |
|
|
|
lucky_loser = models.BooleanField() |
|
|
|
lucky_loser = models.BooleanField() |
|
|
|
@ -384,14 +393,19 @@ class TeamState(models.Model): |
|
|
|
names = map(lambda player: player.name(), self.player_registrations.all()) |
|
|
|
names = map(lambda player: player.name(), self.player_registrations.all()) |
|
|
|
return " - ".join(names) |
|
|
|
return " - ".join(names) |
|
|
|
|
|
|
|
|
|
|
|
def team_name(self): |
|
|
|
def team_names(self): |
|
|
|
|
|
|
|
names = [] |
|
|
|
|
|
|
|
if self.team_registration.name: |
|
|
|
|
|
|
|
names.append(self.team_registration.name) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
names = self.player_names() |
|
|
|
|
|
|
|
|
|
|
|
class Team: |
|
|
|
class Team: |
|
|
|
def __init__(self, image, names, scores, is_winner): |
|
|
|
def __init__(self, image, names, scores, weight, is_winner): |
|
|
|
self.image = image |
|
|
|
self.image = image |
|
|
|
self.names = [] |
|
|
|
self.names = [] |
|
|
|
self.scores = [] |
|
|
|
self.scores = [] |
|
|
|
|
|
|
|
self.weight = weight |
|
|
|
self.is_winner = is_winner |
|
|
|
self.is_winner = is_winner |
|
|
|
|
|
|
|
|
|
|
|
def add_names(self, name): |
|
|
|
def add_names(self, name): |
|
|
|
|