laurent 2 years ago
commit 5961461c88
  1. 2
      tournaments/admin.py
  2. 2
      tournaments/models/group_stage.py
  3. 14
      tournaments/models/match.py
  4. 4
      tournaments/models/round.py
  5. 2
      tournaments/models/tournament.py
  6. 93
      tournaments/static/tournaments/css/style.css
  7. 56
      tournaments/templates/tournaments/broadcasted_group_stages.html
  8. 27
      tournaments/templates/tournaments/broadcasted_match.html
  9. 26
      tournaments/templates/tournaments/broadcasted_matches.html
  10. 9
      tournaments/templates/tournaments/match_cell.html
  11. 2
      tournaments/views.py

@ -30,7 +30,7 @@ class TournamentAdmin(admin.ModelAdmin):
list_display = ['display_name', 'event', 'is_private', 'start_date']
class TeamScoreAdmin(admin.ModelAdmin):
list_display = ['team_registration', 'match', 'score']
list_display = ['team_registration', 'match', 'score', 'walk_out']
class RoundAdmin(admin.ModelAdmin):
list_display = ['tournament', 'name', 'index', 'parent']

@ -49,7 +49,7 @@ class GroupStage(models.Model):
scores1 = ts1.scores()
scores2 = ts2.scores()
if len(scores1) == len(scores2) and len(scores1) > 0:
if match.winning_team_id:
for team_score in match.team_scores.all():
team_registration = team_score.team_registration

@ -178,9 +178,12 @@ class LiveMatch:
self.court = court
self.started = started
self.ended = ended
self.has_walk_out = False
def add_team(self, team):
self.teams.append(team)
if team.walk_out:
self.has_walk_out = True
def to_dict(self):
return {
@ -191,13 +194,14 @@ class LiveMatch:
"court": self.court,
"started": self.started,
"ended": self.ended,
"has_walk_out": self.has_walk_out,
}
def has_walk_out(self):
for team in self.teams:
if team.walk_out:
return True
return False
# def has_walk_out(self):
# for team in self.teams:
# if team.walk_out:
# return True
# return False
def show_duration(self):
for team in self.teams:

@ -42,10 +42,10 @@ class Round(models.Model):
matches.extend(child.ranking_matches(hide_empty_matches))
return matches
def all_matches(self):
def all_matches(self, hide_empty_matches):
matches = []
matches.extend(self.match_set.all())
matches.extend(self.get_matches_recursive(False))
matches.extend(self.get_matches_recursive(hide_empty_matches))
return matches
def get_matches_recursive(self, hide_empty_matches):

@ -192,7 +192,7 @@ class Tournament(models.Model):
def all_matches(self, hide_empty_matches):
matches = []
for round in self.round_set.all():
matches.extend(round.all_matches())
matches.extend(round.all_matches(hide_empty_matches))
for group_stage in self.groupstage_set.all():
matches.extend(group_stage.match_set.all())

@ -51,18 +51,23 @@ header {
a {
color: #707070;
}
a:hover {
color: #f39200;
}
nav {
display: flex; /* Use flexbox */
flex-wrap: wrap; /* Allow items to wrap onto multiple lines */
justify-content: flex-start; /* Align items to the start */
display: flex;
/* Use flexbox */
flex-wrap: wrap;
/* Allow items to wrap onto multiple lines */
justify-content: flex-start;
/* Align items to the start */
}
nav a {
margin-right: 6px; /* Adjust the horizontal spacing between <a> elements */
margin-right: 6px;
/* Adjust the horizontal spacing between <a> elements */
}
/* a {
@ -83,7 +88,9 @@ nav a {
.wrapper {
margin: 0px 10px;
}
@media print, screen and (min-width: 40em) {
@media print,
screen and (min-width: 40em) {
.wrapper {
margin: 0px 40px;
}
@ -159,6 +166,7 @@ tr {
font-size: 1.2em;
/* color: #707070; */
}
.semibold {
font-weight: 600;
}
@ -191,9 +199,11 @@ tr {
.padding-bottom-small {
padding-bottom: 4px;
}
.padding-bottom {
padding-bottom: 20px;
}
.padding-top-small {
padding-top: 4px;
}
@ -201,6 +211,7 @@ tr {
.names {
/* width: 70%; */
}
.team-names-box {
height: 60px;
}
@ -214,29 +225,32 @@ tr {
.player {
flex: 1;
display: flex;
flex-direction: column; /* Stack player names vertically */
flex-direction: column;
/* Stack player names vertically */
}
.scores {
display: flex;
}
.scores span {
/* .score-span {
width: 30px; /* Fixed width for each score cell */
text-align: center;
}
.separator {
*/ .separator {
height: 1px;
background-color: #707070;
margin: 5px 0px;
}
.score {
display: inline-block;
font-size: 1.4em;
vertical-align: middle;
text-align: center;
padding: 0px 5px;
/* width: 30px; */
}
.winner {
@ -307,15 +321,19 @@ svg {
.horizontal-padding {
padding: 0px 20px;
}
.horizontal-margin {
margin: 0px 10px;
}
.hpadding10 {
padding: 0px 10px;
}
.margin10 {
margin: 10px;
}
.left-margin {
margin-left: 10px;
}
@ -374,6 +392,7 @@ svg {
.top-margin {
margin-top: 10px;
}
.top-margin20 {
margin-top: 20px;
}
@ -400,12 +419,15 @@ svg {
.vertical-padding {
padding: 8px 0px;
}
.topmargin5 {
margin-top: 5px;
}
.topmargin10 {
margin-top: 10px;
}
.topmargin20 {
margin-top: 20px;
}
@ -440,6 +462,7 @@ svg {
flex-grow: 1;
text-align: right;
}
.team_image {
height: 40px;
width: 40px;
@ -448,30 +471,39 @@ svg {
.w15 {
width: 15%;
}
.w20 {
width: 20%;
}
.w25 {
width: 25%;
}
.w30 {
width: 30%;
}
.w40 {
width: 40%;
}
.w50 {
width: 50%;
}
.w60 {
width: 60%;
}
.w70 {
width: 70%;
}
.w80 {
width: 80%;
}
.w100 {
width: 100%;
}
@ -479,18 +511,27 @@ svg {
.w20px {
width: 20px;
}
.w30px {
width: 30px;
}
.w40px {
width: 40px;
}
.w60px {
width: 60px;
}
.w70px {
width: 7px;
}
.w80px {
width: 80px;
}
.w100px {
width: 100px;
}
@ -498,35 +539,44 @@ svg {
.table-row-2-colums {
display: grid;
grid-template-columns: 2fr 60px;
align-items: center; /* Vertically center the content within each column */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
.table-row-2-colums-test {
display: grid;
grid-template-columns: 1px auto 100px;
align-items: center; /* Vertically center the content within each column */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
.table-row-3-colums {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center; /* Vertically center the content within each column */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
.table-row-4-colums {
display: grid;
grid-template-columns: 1px auto 50px 70px 100px; /* first column is a hack */
align-items: center; /* Vertically center the content within each column */
grid-template-columns: 1px auto 50px 70px 100px;
/* first column is a hack */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
@media print, screen and (min-width: 80em) {
@media print,
screen and (min-width: 80em) {
.table-row-4-colums {
display: grid;
grid-template-columns: 1px auto 50px 70px 180px; /* first column is a hack */
align-items: center; /* Vertically center the content within each column */
grid-template-columns: 1px auto 50px 70px 180px;
/* first column is a hack */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
}
@ -534,7 +584,8 @@ svg {
.table-row-5-colums {
display: grid;
grid-template-columns: 60px auto 50px 70px 130px;
align-items: center; /* Vertically center the content within each column */
align-items: center;
/* Vertically center the content within each column */
padding: 5px 0px;
}
@ -545,7 +596,8 @@ svg {
}
.table-cell-large {
grid-column: 2 / span 1; /* Center column spans from column 2 to column 3 */
grid-column: 2 / span 1;
/* Center column spans from column 2 to column 3 */
text-align: left;
}
@ -553,7 +605,8 @@ svg {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 100vh; /*the height will need to be customized*/
height: 100vh;
/*the height will need to be customized*/
width: 50px;
}

@ -78,62 +78,6 @@
{% include 'tournaments/broadcasted_group_stage.html' %}
<!-- <div class="dark_bubble">
<div class="flex-row">
<label class="left-label matchtitle winner"><span x-text="group_stage.title"></span></label>
</div>
<template x-for="i in group_stage.teams.length">
<div>
<div class="flex dark-bottom-border">
<div class="flex-left">
<template x-for="name in group_stage.teams[i-1].names">
<div class="semibold" x-data="{
showName(name, team) {
let html = `<span class='`
if (team.is_winner) html += `winner`
html += `'>`
html += name
html += `</span>`
return html
},
}" x-html="showName(name, group_stage.teams[i-1])">
</div>
</template>
</div>
<div class="flex-right">
<div x-show="group_stage.teams[i-1].match_count == 0">
<div class="score ws"><span x-text="group_stage.teams[i-1].weight"></span></div>
</div>
<div x-show="group_stage.teams[i-1].match_count > 0">
<div class="center">
<div class="score ws"><span x-text="group_stage.teams[i-1].win_loss"></span></div>
<div class="ws"><span x-text="group_stage.teams[i-1].diff"></span></div>
</div>
</div>
</div>
</div>
<div x-show="i != group_stage.teams.length">
<div class="dark-bottom-border"></div>
</div>
</div>
</template>
<div class="top-margin flex-row">
<label class="left-label minor-info"><span class="beige" x-text="group_stage.duration"></span></label>
</div>
</div> -->
</div>
</template>

@ -34,6 +34,13 @@
html += `'>`
html += score
html += `</span>`
if (match.has_walk_out) {
html += `<span class='score ws w60px'>`
if (team.walk_out) html += `WO`
html += `</span>`
}
return html
},
}" x-html="showScore(score, match.teams[i-1])">
@ -42,6 +49,26 @@
</div>
</div>
<!--
{% if match.started %}
{% for score in team.scores %}
<div class="scores">
<span class="score ws{% if team.is_winner %} winner{% endif %}">{{ score }}</span>
</div>
{% endfor %}
{% if match.has_walk_out %}
<span class="score ws w60px">
{% if team.walk_out %}WO{% endif %}
</span>
{% endif %}
{% else %}
<span class="score ws">{{ team.weight }}</span>
{% endif %}
-->
<div x-show="i === 1">
<div class="bottom-border"></div>
</div>

@ -82,9 +82,9 @@
<template x-for="i in match.teams.length">
<div>
<div class="table-row-3-colums team-names-box padding-bottom-small">
<div class="match-result">
<div class="table-cell table-cell-large">
<div class="player">
<template x-for="name in match.teams[i-1].names">
<div class="ws" x-data="{
@ -101,12 +101,12 @@
</template>
</div>
<div class="table-cell alignright">
<div class="scores">
<template x-for="score in match.teams[i-1].scores">
<span class="score ws" x-data="{
<span x-data="{
showScore(score, team) {
let html = `<span class='`
let html = `<span class='score ws w30px`
if (team.is_winner) html += ` winner`
html += `'>`
html += score
@ -116,8 +116,22 @@
}" x-html="showScore(score, match.teams[i-1])">
</span>
<!-- <span class="score ws" x-text="score"></span> -->
</template>
<span x-data="{
showWalkOut(match, team) {
let html = ``
if (match.has_walk_out) {
html += `<span class='score ws w60px'>`
if (team.walk_out) html += `WO`
html += `</span>`
}
return html
},
}" x-html="showWalkOut(match, match.teams[i-1])">
</span>
</div>
</div>

@ -20,12 +20,11 @@
</div>
{% endfor %}
</div>
<!-- <div class="scores"> -->
{% if match.started %}
{% for score in team.scores %}
<div class="scores">
<span class="score ws{% if team.is_winner %} winner{% endif %}">{{ score }}</span>
</div>
{% for score in team.scores %}
<span class="score ws w30px{% if team.is_winner %} winner{% endif %}">{{ score }}</span>
{% endfor %}
{% if match.has_walk_out %}
@ -33,11 +32,11 @@
{% if team.walk_out %}WO{% endif %}
</span>
{% endif %}
</div>
{% else %}
<span class="score ws">{{ team.weight }}</span>
{% endif %}
<!-- </div> -->
</div>
{% endfor %}

@ -156,7 +156,7 @@ def broadcast_json(request, tournament_id):
def tournament_matches_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
matches, group_stages = tournament.broadcasted_content()
matches, group_stages = tournament.broadcasted_matches_and_group_stages()
live_matches = [match.live_match() for match in matches]
data = json.dumps(live_matches, default=vars)

Loading…
Cancel
Save