- diff --git a/tournaments/models/event.py b/tournaments/models/event.py index dcd0838..03eb76d 100644 --- a/tournaments/models/event.py +++ b/tournaments/models/event.py @@ -16,3 +16,9 @@ class Event(models.Model): def __str__(self): return self.name + + def display_name(self): + if self.name: + return self.name + else: + return self.club.name diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py index f2b44b3..167914b 100644 --- a/tournaments/models/group_stage.py +++ b/tournaments/models/group_stage.py @@ -21,3 +21,30 @@ class GroupStage(models.Model): def matches_for_registration(self, player_registration): team_scores = TeamScore.objects.filter(player_registrations=player_registration) return map(lambda ts: ts.match, team_scores) + + def live_group_stage(self): + lgs = LiveGroupStage(self.name()) + for team_registration in self.teamregistration_set.all(): + team = GroupStageTeam(team_registration.team_names(), self.score(), self.diff()) + lgs.add_team(team) + return lgs + + def score(self): + return "2-0" + + def diff(self): + return "+6" + +class LiveGroupStage: + def __init__(self, title): + self.title = title + self.teams = [] + + def add_team(self, team): + self.teams.append(team) + +class GroupStageTeam: + def __init__(self, names, score, diff): + self.names = names + self.score = score + self.diff = diff diff --git a/tournaments/models/match.py b/tournaments/models/match.py index e3b8f94..515b8bd 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -52,6 +52,9 @@ class Match(models.Model): else: return (timezone.now() - self.start_date).total_seconds() + def started(self): + return timezone.now() > self.start_date + def durationPrefix(self): if self.current_duration() > 0: return "Temps de jeu" @@ -82,7 +85,8 @@ class Match(models.Model): court = "" if self.court: court = f"Terrain {self.court}" - livematch = LiveMatch(title, date, duration, court) + + livematch = LiveMatch(title, date, duration, court, self.started()) for team_score in self.team_scores.all(): image = team_score.team_registration.logo @@ -104,15 +108,13 @@ class Team: self.is_winner = is_winner class LiveMatch: - def __init__(self, title, date, duration, court): + def __init__(self, title, date, duration, court, started): self.title = title self.date = date self.teams = [] self.duration = duration self.court = court + self.started = started def add_team(self, team): self.teams.append(team) - - # def toJSON(self): - # return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) diff --git a/tournaments/models/team_score.py b/tournaments/models/team_score.py index f149b50..519f39d 100644 --- a/tournaments/models/team_score.py +++ b/tournaments/models/team_score.py @@ -27,4 +27,7 @@ class TeamScore(models.Model): return names def scores_array(self): - return [int(x) for x in self.score.split(',')] + if self.score: + return [int(x) for x in self.score.split(',')] + else: + return [] diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 625a642..3b2e974 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -74,6 +74,9 @@ class Tournament(models.Model): return map(lambda match: match.live_match(), matches) + def live_group_stages(self): + return map(lambda gs: gs.live_group_stage(), self.groupstage_set.all()) + class TeamSummon: def __init__(self, names, date, weight, stage, image): self.names = [] diff --git a/tournaments/static/tournaments/css/broadcast.css b/tournaments/static/tournaments/css/broadcast.css index 3c52c41..f5fd40a 100644 --- a/tournaments/static/tournaments/css/broadcast.css +++ b/tournaments/static/tournaments/css/broadcast.css @@ -14,5 +14,6 @@ body { padding: 20px; background-color: white; border-radius: 24px; - /* box-shadow: 10px 10px lightblue; */ + /* box-shadow: 0 0 0px 1px #fbead6; */ + box-shadow: 0 0 0px 0px #fbead6; } diff --git a/tournaments/templates/tournaments/base.html b/tournaments/templates/tournaments/base.html index fbcde98..d3c502e 100644 --- a/tournaments/templates/tournaments/base.html +++ b/tournaments/templates/tournaments/base.html @@ -27,17 +27,17 @@
-