|
|
|
|
@ -134,7 +134,7 @@ class Match(models.Model): |
|
|
|
|
is_winner = False |
|
|
|
|
scores = [] |
|
|
|
|
walk_out = None |
|
|
|
|
team = Team(None, image, names, scores, weight, is_winner, walk_out) |
|
|
|
|
team = Team(None, image, names, scores, weight, is_winner, walk_out, False) |
|
|
|
|
return team |
|
|
|
|
|
|
|
|
|
def is_ready(self): |
|
|
|
|
@ -188,9 +188,11 @@ class Match(models.Model): |
|
|
|
|
teams.append(team) |
|
|
|
|
else: |
|
|
|
|
teams.append(existing_team) |
|
|
|
|
else: |
|
|
|
|
elif len(team_scores) == 2: |
|
|
|
|
# Both team scores present |
|
|
|
|
teams.extend([team_score.live_team(self) for team_score in team_scores]) |
|
|
|
|
else: |
|
|
|
|
teams.extend([team_score.live_team(self) for team_score in team_scores if team_score.walk_out != 1]) |
|
|
|
|
|
|
|
|
|
return teams |
|
|
|
|
|
|
|
|
|
@ -353,7 +355,7 @@ class Match(models.Model): |
|
|
|
|
# return sort_score |
|
|
|
|
|
|
|
|
|
class Team: |
|
|
|
|
def __init__(self, id, image, names, scores, weight, is_winner, walk_out): |
|
|
|
|
def __init__(self, id, image, names, scores, weight, is_winner, walk_out, is_lucky_loser): |
|
|
|
|
# print(f"image = {image}, names= {names}, scores ={scores}, weight={weight}, win={is_winner}") |
|
|
|
|
self.id = str(id) |
|
|
|
|
self.image = image |
|
|
|
|
@ -361,7 +363,11 @@ class Team: |
|
|
|
|
self.scores = scores |
|
|
|
|
self.weight = weight |
|
|
|
|
self.is_winner = is_winner |
|
|
|
|
self.walk_out = walk_out is not None |
|
|
|
|
self.walk_out = walk_out |
|
|
|
|
self.is_lucky_loser = is_lucky_loser |
|
|
|
|
|
|
|
|
|
def is_walk_out(self): |
|
|
|
|
return self.walk_out is not None |
|
|
|
|
|
|
|
|
|
def to_dict(self): |
|
|
|
|
return { |
|
|
|
|
@ -371,6 +377,8 @@ class Team: |
|
|
|
|
"weight": self.weight, |
|
|
|
|
"is_winner": self.is_winner, |
|
|
|
|
"walk_out": self.walk_out, |
|
|
|
|
"is_walk_out": self.is_walk_out(), |
|
|
|
|
"is_lucky_loser": self.is_lucky_loser |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class LiveMatch: |
|
|
|
|
@ -388,7 +396,7 @@ class LiveMatch: |
|
|
|
|
|
|
|
|
|
def add_team(self, team): |
|
|
|
|
self.teams.append(team) |
|
|
|
|
if team.walk_out is True: |
|
|
|
|
if team.is_walk_out() is True: |
|
|
|
|
self.has_walk_out = True |
|
|
|
|
|
|
|
|
|
def to_dict(self): |
|
|
|
|
@ -407,7 +415,7 @@ class LiveMatch: |
|
|
|
|
|
|
|
|
|
def show_time_indication(self): |
|
|
|
|
for team in self.teams: |
|
|
|
|
if team.walk_out and len(team.scores) == 0: |
|
|
|
|
if team.is_walk_out() and len(team.scores) == 0: |
|
|
|
|
return False |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|