diff --git a/static/tournaments/css/style.css b/static/tournaments/css/style.css index d69aacb..d6bd29d 100644 --- a/static/tournaments/css/style.css +++ b/static/tournaments/css/style.css @@ -79,10 +79,6 @@ a:hover { } } -.beige { - color: #fff7ed; -} - .mybox { color: #707070; padding: 8px 12px; @@ -115,6 +111,10 @@ tr { /* height: 40px; */ } +.beige { + color: red; +} + .topblock { margin-top: 20px; } diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py index 6f9fb82..cf9b36a 100644 --- a/tournaments/models/group_stage.py +++ b/tournaments/models/group_stage.py @@ -2,6 +2,8 @@ from django.db import models from . import Tournament, FederalMatchCategory import uuid from ..utils.extensions import format_seconds +from datetime import datetime, timedelta +from django.utils import timezone class GroupStage(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) @@ -21,7 +23,7 @@ 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) + return [ts.match for ts in team_scores] # map(lambda ts: ts.match, team_scores) def live_group_stages(self): lgs = LiveGroupStage(self.name()) @@ -67,7 +69,8 @@ class GroupStage(models.Model): team1.diff = total1 - total2 team2.diff = total2 - total1 - for team in gs_teams.values(): + teams = sorted(gs_teams.values(), key=lambda t: t.position) + for team in teams: lgs.add_team(team) return lgs @@ -98,9 +101,29 @@ class LiveGroupStage: else: return "--" + def to_dict(self): + return { + "title": self.title, + "teams": [team.to_dict() for team in self.teams], + "duration": self.formatted_duration() + } + + def lean(self): + leanteams = [] + for team in self.teams: + leanteams.append(team.lean()) + return LeanGroupStage(self.title, [], self.formatted_duration()) + +class LeanGroupStage: + def __init__(self, title, teams, duration): + self.title = title + self.teams = teams + self.duration = duration + class GroupStageTeam: def __init__(self, team_registration): self.names = team_registration.team_names() + self.position = team_registration.group_stage_position self.wins = 0 self.losses = 0 self.diff = 0 @@ -113,3 +136,19 @@ class GroupStageTeam: return f"+{self.diff}" else: return f"{self.diff}" + + def to_dict(self): + return { + "names": self.names, + "win_loss": self.wins_losses(), + "diff": self.formatted_diff() + } + + def lean(self): + return LeanTeam(self.names, self.wins_losses(), self.formatted_diff()) + +class LeanTeam: + def __init__(self, names, winloss, diff): + self.names = names + self.winloss = winloss + self.diff = diff diff --git a/tournaments/models/team_registration.py b/tournaments/models/team_registration.py index e7974a2..fb87fc6 100644 --- a/tournaments/models/team_registration.py +++ b/tournaments/models/team_registration.py @@ -24,10 +24,10 @@ class TeamRegistration(models.Model): if self.name: return [self.name] else: - return map(lambda pr: pr.name(), self.playerregistration_set.all()) + return [pr.name() for pr in self.playerregistration_set.all()] def player_names(self): - names = map(lambda pr: pr.name(), self.playerregistration_set.all()) + names = [pr.name() for pr in self.playerregistration_set.all()] str = " - ".join(names) if len(str) > 0: return str @@ -43,20 +43,6 @@ class TeamRegistration(models.Model): else: return all_matches[0] - # match = self.first_match(False) - # if match: - # return match - # else: - # return self.first_match(True) - - # def first_match(self, completed): - # q_base = Q(team_scores__team_registration==self) - # q = Q(end_date__isnull=not completed, start_date__isnull=False) - # q_round = Q(round__tournament=self.tournament) - # q_group_stage = Q(group_stage__tournament=self.tournament) - # matches = Match.objects.filter(q_base, q, q_round | q_group_stage).order_by('start_date') - # return matches[0] - def next_stage(self): matches = map(lambda ts: ts.match, self.teamscore_set.all()) matches = [m for m in matches if m.group_stage is None] @@ -64,7 +50,7 @@ class TeamRegistration(models.Model): # matches = self.teamscore_set # matches = Match.objects.filter(group_stage__isnull=True, team_scores__player_registrations__id=self.id).order_by('round__index') - print(f"matches = {len(matches)}") + # print(f"matches = {len(matches)}") if matches: return matches[0].round.name() elif self.group_stage: diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 7495cec..9061d69 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1,6 +1,7 @@ from django.db import models from . import Event, CustomUser, FederalMatchCategory, FederalCategory, FederalLevelCategory, FederalAgeCategory import uuid +from django.utils import timezone, formats class Tournament(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) @@ -79,16 +80,30 @@ class Tournament(models.Model): # matches = [m for m in matches if len(m.team_scores.all()) > 0] matches.sort(key=lambda m: m.order) - return map(lambda match: match.live_match(), matches) + return [match.live_match() for match in matches] + # return map(lambda match: match.live_match(), matches) def live_group_stages(self): - return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all()) + return [gs.live_group_stages() for gs in self.groupstage_set.all()] + # return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all()) class TeamSummon: def __init__(self, names, date, weight, stage, image): - self.names = [] self.names = names self.date = date self.weight = weight self.stage = stage self.image = image + + def formatted_date(self): + timezoned_datetime = timezone.localtime(self.date) + return formats.date_format(timezoned_datetime, format='H:i') + + def to_dict(self): + return { + "names": self.names, + "date": self.formatted_date(), + "weight": self.weight, + "stage": self.stage, + "image": self.image, + } diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index d69aacb..1c91020 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -79,10 +79,6 @@ a:hover { } } -.beige { - color: #fff7ed; -} - .mybox { color: #707070; padding: 8px 12px; @@ -115,6 +111,10 @@ tr { /* height: 40px; */ } +.beige { + color: #fff7ed; +} + .topblock { margin-top: 20px; } diff --git a/tournaments/templates/tournaments/base.html b/tournaments/templates/tournaments/base.html index 443ff28..84b09ae 100644 --- a/tournaments/templates/tournaments/base.html +++ b/tournaments/templates/tournaments/base.html @@ -21,30 +21,30 @@ -
-
-
- - -
-

{% block first_title %}Page Title{% endblock %}

-

{% block second_title %}Page Title{% endblock %}

- -
- -
+
+
+
+ + +
+

{% block first_title %}Page Title{% endblock %}

+

{% block second_title %}Page Title{% endblock %}

+ +
+
-
+
+
-
- - {% block content %} - - {% endblock %} -
+
+ + {% block content %} + + {% endblock %} +
diff --git a/tournaments/templates/tournaments/broadcast.html b/tournaments/templates/tournaments/broadcast.html new file mode 100644 index 0000000..a7e4a93 --- /dev/null +++ b/tournaments/templates/tournaments/broadcast.html @@ -0,0 +1,22 @@ +{% extends 'tournaments/broadcast_base.html' %} + +{% load static %} + +{% block head_title %}Broadcast{% endblock %} +{% block first_title %}{{ tournament.event.display_name }}{% endblock %} +{% block second_title %}Broadcast{% endblock %} + +{% block content %} + +
+
+ + +
+
+ +{% endblock %} diff --git a/tournaments/templates/tournaments/broadcast_base.html b/tournaments/templates/tournaments/broadcast_base.html new file mode 100644 index 0000000..3dca010 --- /dev/null +++ b/tournaments/templates/tournaments/broadcast_base.html @@ -0,0 +1,54 @@ + + + {% load static %} + + + + + + + + + + + + {% block head_title %}Page Title{% endblock %} + + + + +
+
+
+
+
+ +
+

{% block first_title %}Page Title{% endblock %}

+

{% block second_title %}Page Title{% endblock %}

+ +
+
+
+
+
+ +
+ + {% block content %} + + {% endblock %} +
+
+ + diff --git a/tournaments/templates/tournaments/broadcasted_group_stages.html b/tournaments/templates/tournaments/broadcasted_group_stages.html index e69de29..8ff5232 100644 --- a/tournaments/templates/tournaments/broadcasted_group_stages.html +++ b/tournaments/templates/tournaments/broadcasted_group_stages.html @@ -0,0 +1,131 @@ + +{% load static %} + + + + + + + + + + Padel + + + + + + + +
+
+
+ +
+
+
+ +
+

{{ tournament.name }}

+

Poules

+ +
+
+
+
+ +
+ + + +
+ +
+
+
+ + + diff --git a/tournaments/templates/tournaments/broadcasted_matches.html b/tournaments/templates/tournaments/broadcasted_matches.html index c632674..f01256d 100644 --- a/tournaments/templates/tournaments/broadcasted_matches.html +++ b/tournaments/templates/tournaments/broadcasted_matches.html @@ -19,7 +19,7 @@ paginatedMatches: null, active: 1, retrieveMatches() { - fetch('/tournament/{{ tournament.id }}/matches-json/') + fetch('/tournament/{{ tournament.id }}/matches/json/') .then(res => res.json()) .then((data) => { this.paginatedMatches = this.paginate(data, 8) @@ -41,10 +41,8 @@ } }" x-init="loop()"> -
-
-
+
@@ -54,7 +52,7 @@ class="logo inline" />
-

4Padel Toulouse

+

{{ tournament.name }}

Matchs

@@ -80,12 +78,6 @@
- -