clubs
Laurent 2 years ago
parent 9d68095095
commit c21e625418
  1. 4
      padelclub_backend/settings.py
  2. 31
      tournaments/models/match.py
  3. 26
      tournaments/models/team_registration.py
  4. 8
      tournaments/models/team_score.py
  5. 10
      tournaments/models/tournament.py
  6. 12
      tournaments/static/tournaments/css/style.css
  7. 2
      tournaments/templates/tournaments/broadcasted_matches.html
  8. 14
      tournaments/templates/tournaments/match_cell.html
  9. 7
      tournaments/templates/tournaments/summon_row.html

@ -109,9 +109,9 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/ # https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'fr'
TIME_ZONE = 'Europe/Paris' TIME_ZONE = 'CET'
USE_I18N = True USE_I18N = True

@ -33,11 +33,20 @@ class Match(models.Model):
items = [] items = []
if self.round: if self.round:
items.append(self.round.name()) items.append(self.round.name())
items.append(f" #{self.index}")
elif self.group_stage: elif self.group_stage:
items.append(self.group_stage.name()) items.append(self.group_stage.name())
items.append(f"{self.index}") items.append(f"Match #{self.index}")
return " ".join(items) return " ".join(items)
def stage_name(self):
if self.round:
return self.round.name()
elif self.group_stage:
return self.group_stage.name()
else:
return '--'
def player_names(self): def player_names(self):
return map(lambda ts: ts.player_names(), self.team_scores.all()) return map(lambda ts: ts.player_names(), self.team_scores.all())
@ -48,6 +57,18 @@ class Match(models.Model):
return '' return ''
# return str(self.start_date) #.strftime("%H:%M") # return str(self.start_date) #.strftime("%H:%M")
def time_indication(self):
if self.end_date:
return self.formatted_duration()
elif self.start_date:
if self.started():
return self.formatted_duration()
else:
start = self.start_date.strftime("%H:%M")
return f"Prévu à {start}"
else:
return 'À venir...'
def current_duration(self): def current_duration(self):
if self.end_date: if self.end_date:
return (self.end_date - self.start_date).total_seconds() return (self.end_date - self.start_date).total_seconds()
@ -62,12 +83,6 @@ class Match(models.Model):
else: else:
return False return False
def durationPrefix(self):
if self.current_duration() > 0:
return "Temps de jeu"
else:
return "Démarrage prévu dans"
def formatted_duration(self): def formatted_duration(self):
_seconds = self.current_duration() _seconds = self.current_duration()
@ -88,7 +103,7 @@ class Match(models.Model):
def live_match(self): def live_match(self):
title = self.name() title = self.name()
date = self.formatted_start_date() date = self.formatted_start_date()
duration = self.formatted_duration() duration = self.time_indication()
court = "" court = ""
if self.court: if self.court:
court = f"Terrain {self.court}" court = f"Terrain {self.court}"

@ -1,5 +1,6 @@
from django.db import models from django.db import models
from . import Tournament, GroupStage from django.db.models.sql.query import Q
from . import Tournament, GroupStage, Match
import uuid import uuid
class TeamRegistration(models.Model): class TeamRegistration(models.Model):
@ -33,6 +34,29 @@ class TeamRegistration(models.Model):
else: else:
return "no players" return "no players"
def next_match(self):
all_matches = map(lambda ts: ts.match, self.teamscore_set.all())
all_matches = sorted(all_matches, key=lambda m: m.start_date)
matches = [m for m in all_matches if m.end_date is None]
if matches:
return matches[0]
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): def next_stage(self):
matches = map(lambda ts: ts.match, self.teamscore_set.all()) matches = map(lambda ts: ts.match, self.teamscore_set.all())
matches = [m for m in matches if m.group_stage is None] matches = [m for m in matches if m.group_stage is None]

@ -27,7 +27,9 @@ class TeamScore(models.Model):
return names return names
def scores_array(self): def scores_array(self):
scores = []
if self.score: if self.score:
return [int(x) for x in self.score.split(',')] scores = [x for x in self.score.split(',')]
else: if self.walk_out == 1:
return [] scores.insert(0, 'WO')
return scores

@ -56,12 +56,12 @@ class Tournament(models.Model):
summons = [] summons = []
for team_registration in self.teamregistration_set.all(): for team_registration in self.teamregistration_set.all():
call_date = team_registration.call_date next_match = team_registration.next_match()
if call_date: if next_match:
names = team_registration.team_names() names = team_registration.team_names()
stage = team_registration.next_stage() stage = next_match.stage_name()
weight = team_registration.weight() weight = team_registration.weight()
summon = TeamSummon(names, call_date, weight, stage, team_registration.logo) summon = TeamSummon(names, next_match.start_date, weight, stage, team_registration.logo)
summons.append(summon) summons.append(summon)
return summons return summons
@ -75,7 +75,7 @@ class Tournament(models.Model):
for match in round.match_set.all(): for match in round.match_set.all():
matches.append(match) matches.append(match)
# matches = [m for m in matches if m.broadcasted==True] matches = [m for m in matches if m.broadcasted==True]
return map(lambda match: match.live_match(), matches) return map(lambda match: match.live_match(), matches)

@ -182,6 +182,9 @@ tr {
.names { .names {
/* width: 70%; */ /* width: 70%; */
} }
.team-names-box {
height: 60px;
}
.scores { .scores {
vertical-align: middle; vertical-align: middle;
@ -348,7 +351,7 @@ tr {
.flex-row { .flex-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
height: 29px; /* height: 29px; */
align-items: center; align-items: center;
/* vertical-align: middle; */ /* vertical-align: middle; */
} }
@ -421,6 +424,13 @@ tr {
padding: 5px 0px; padding: 5px 0px;
} }
.table-row-4-colums {
display: grid;
grid-template-columns: 1px auto 50px 70px 130px; /* first column is a hack */
align-items: center; /* Vertically center the content within each column */
padding: 5px 0px;
}
.table-row-5-colums { .table-row-5-colums {
display: grid; display: grid;
grid-template-columns: 60px auto 50px 70px 130px; grid-template-columns: 60px auto 50px 70px 130px;

@ -37,7 +37,7 @@
setInterval(() => { setInterval(() => {
this.retrieveMatches() this.retrieveMatches()
this.active = this.active === this.paginatedMatches.length ? 1 : this.active+1 this.active = this.active === this.paginatedMatches.length ? 1 : this.active+1
}, 3000) }, 30000)
} }
}" x-init="loop()"> }" x-init="loop()">

@ -5,21 +5,21 @@
<div class="flex-row"> <div class="flex-row">
<label class="left-label matchtitle">{{ match.title }}</label> <label class="left-label matchtitle">{{ match.title }}</label>
<label class="right-label info">{{ match.date }}</label> <!-- <label class="right-label info">{{ match.date }}</label> -->
</div> </div>
<div> <div>
{% for team in match.teams %} {% for team in match.teams %}
<div class="table-row-3-colums {% cycle 'bottom-border' '' %} padding-bottom-small"> <div class="table-row-3-colums team-names-box {% cycle 'bottom-border' '' %} padding-bottom-small">
{% if team.image %} <!-- {% if team.image %}
<div class="table-cell"> <div class="table-cell">
<img src="{% static 'tournaments/images/pc_icon_round_200.png' %}" class="team_image" /> <img src="{% static 'tournaments/images/pc_icon_round_200.png' %}" class="team_image" />
</div> </div>
{% endif %} {% endif %} -->
<div class="table-cell table-cell-large horizontal-padding"> <div class="table-cell table-cell-large hpadding10">
{% for name in team.names %} {% for name in team.names %}
<div class="semibold {% if team.is_winner %}winner{% endif %}"> <div class="semibold {% if team.is_winner %}winner{% endif %}">
{{ name }} {{ name }}
@ -42,8 +42,8 @@
</div> </div>
<div class="top-margin flex-row"> <div class="flex-row top-margin">
<label class="left-label minor-info">{{ match.duration }}</label> <label class="left-label minor-info semibold">{{ match.duration }}</label>
<label class="right-label minor-info">{{ match.court }}</label> <label class="right-label minor-info">{{ match.court }}</label>
<!-- <a href="" class="right-label">{{ match.court }}</a> --> <!-- <a href="" class="right-label">{{ match.court }}</a> -->
</div> </div>

@ -1,10 +1,7 @@
{% load static %} {% load static %}
<div class="table-row-5-colums bottom-border"> <div class="table-row-4-colums bottom-border">
<div class="table-cell">
<img class="team_image horizontal-margin" src="{% static 'tournaments/images/pc_icon_round_200.png' %}" />
</div>
<!-- <img src="{% static 'tournaments/images/{{ team_call.image }}' %}" class="team_image horizontal-margin"> -->
<div class="table-cell table-cell-large semibold"> <div class="table-cell table-cell-large semibold">
{% for name in summon.names %} {% for name in summon.names %}
<div>{{ name }}</div> <div>{{ name }}</div>

Loading…
Cancel
Save