From 7ac58ffd7397cbca4a2b6b2912fbfb33f284979b Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 28 Mar 2024 16:31:25 +0100 Subject: [PATCH] First commit for broadcast page --- tournaments/models/group_stage.py | 10 +- tournaments/models/match.py | 19 +++ tournaments/models/round.py | 2 +- tournaments/models/tournament.py | 4 +- .../templates/tournaments/broadcasted.html | 90 +++++++++++ .../tournaments/broadcasted_group_stage.html | 48 ++++++ .../tournaments/broadcasted_match.html | 63 ++++++++ .../tournaments/broadcasted_matches.html | 140 +++++++++--------- .../tournaments/broadcasted_summon.html | 15 ++ .../tournaments/broadcasted_summons.html | 6 - tournaments/urls.py | 1 + tournaments/views.py | 22 ++- 12 files changed, 334 insertions(+), 86 deletions(-) create mode 100644 tournaments/templates/tournaments/broadcasted.html create mode 100644 tournaments/templates/tournaments/broadcasted_group_stage.html create mode 100644 tournaments/templates/tournaments/broadcasted_match.html create mode 100644 tournaments/templates/tournaments/broadcasted_summon.html diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py index f63f13b..b9efcaf 100644 --- a/tournaments/models/group_stage.py +++ b/tournaments/models/group_stage.py @@ -142,8 +142,8 @@ class GroupStageTeam: return f"{self.diff}" def to_dict(self): - return { - "names": self.names, - "win_loss": self.wins_losses(), - "diff": self.formatted_diff() - } + return { + "names": self.names, + "win_loss": self.wins_losses(), + "diff": self.formatted_diff() + } diff --git a/tournaments/models/match.py b/tournaments/models/match.py index d0c05d8..a163f2c 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -155,6 +155,15 @@ class Team: self.weight = weight self.is_winner = is_winner + # def to_dict(self): + # return { + # "image": self.image, + # "names": self.names, + # "scores": self.scores, + # "weight": self.weight, + # "is_winner": self.is_winner, + # } + class LiveMatch: def __init__(self, title, date, duration, court, started): self.title = title @@ -166,3 +175,13 @@ class LiveMatch: def add_team(self, team): self.teams.append(team) + + # def to_dict(self): + # return { + # "title": self.title, + # "date": self.date, + # "teams": [team.to_dict() for team in self.teams], + # "duration": self.duration, + # "court": self.court, + # "started": self.started, + # } diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 627efaa..0a8b2c0 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -42,6 +42,6 @@ class Round(models.Model): return matches def all_matches(self): - matches = self.match_set.all() + matches = list(self.match_set.all()) matches.extend(self.ranking_matches(True)) return matches diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 7ee277a..a43206b 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -151,7 +151,7 @@ class Tournament(models.Model): else: matches = self.group_stages_matches() - return matches + return [match.live_match() for match in matches] def last_match(self): matches = [] @@ -161,7 +161,7 @@ class Tournament(models.Model): matches.extend(group_stage.match_set.all()) matches = [m for m in matches if m.start_date] - matches.sort(key=lambda m: -m.start_date) + matches.sort(key=lambda m: m.start_date, reverse=True) return matches[0] def round_for_index(self, index): diff --git a/tournaments/templates/tournaments/broadcasted.html b/tournaments/templates/tournaments/broadcasted.html new file mode 100644 index 0000000..176220e --- /dev/null +++ b/tournaments/templates/tournaments/broadcasted.html @@ -0,0 +1,90 @@ +{% extends 'tournaments/broadcast_base.html' %} + +{% block head_title %}Convocations{% endblock %} +{% block first_title %}{{ tournament.name }}{% endblock %} +{% block second_title %}Convocations{% endblock %} + +{% block content %} + +{% load static %} + +
+ +
+ + + + + + + +
+
+ +{% endblock %} diff --git a/tournaments/templates/tournaments/broadcasted_group_stage.html b/tournaments/templates/tournaments/broadcasted_group_stage.html new file mode 100644 index 0000000..463a48a --- /dev/null +++ b/tournaments/templates/tournaments/broadcasted_group_stage.html @@ -0,0 +1,48 @@ +
+ +
+ + +
+ + + +
+ + +
+ +
diff --git a/tournaments/templates/tournaments/broadcasted_match.html b/tournaments/templates/tournaments/broadcasted_match.html new file mode 100644 index 0000000..7a07e7e --- /dev/null +++ b/tournaments/templates/tournaments/broadcasted_match.html @@ -0,0 +1,63 @@ +
+ +
+ + +
+ + + +
+ + +
+ +
diff --git a/tournaments/templates/tournaments/broadcasted_matches.html b/tournaments/templates/tournaments/broadcasted_matches.html index b6632c9..b6223d5 100644 --- a/tournaments/templates/tournaments/broadcasted_matches.html +++ b/tournaments/templates/tournaments/broadcasted_matches.html @@ -44,97 +44,97 @@
-
-
-
- -
-

{{ tournament.name }}

-

Matchs

- -
+
+
+
+ +
+

{{ tournament.name }}

+

Matchs

+
+
-
+
-