fix broadcast auto, add rankings to broadcast auto

tz
Raz 1 year ago
parent 2f314d7a95
commit ccb9cf0b27
  1. 19
      tournaments/models/tournament.py
  2. 13
      tournaments/static/tournaments/css/broadcast.css
  3. 77
      tournaments/templates/tournaments/broadcast/broadcasted_auto.html
  4. 34
      tournaments/templates/tournaments/broadcast/broadcasted_ranking.html
  5. 9
      tournaments/templates/tournaments/broadcast/broadcasted_rankings.html

@ -451,6 +451,7 @@ class Tournament(models.Model):
'matches': [], 'matches': [],
'group_stages': group_stages_dicts, 'group_stages': group_stages_dicts,
'summons': team_summons_dicts, 'summons': team_summons_dicts,
'rankings' : []
} }
else: else:
live_matches_dicts = [match.live_match().to_dict() for match in matches] live_matches_dicts = [match.live_match().to_dict() for match in matches]
@ -458,13 +459,24 @@ class Tournament(models.Model):
'matches': live_matches_dicts, 'matches': live_matches_dicts,
'group_stages': [], 'group_stages': [],
'summons': team_summons_dicts, 'summons': team_summons_dicts,
'rankings' : []
} }
elif self.end_date is not None:
live_matches_dicts = [match.live_match().to_dict() for match in matches]
team_rankings_dicts = [ranking.to_dict() for ranking in self.rankings()]
return {
'matches': live_matches_dicts,
'group_stages': [],
'summons': [],
'rankings' : team_rankings_dicts
}
else: # we want to display the broadcasted content else: # we want to display the broadcasted content
live_matches_dicts = [match.live_match().to_dict() for match in matches] live_matches_dicts = [match.live_match().to_dict() for match in matches]
return { return {
'matches': live_matches_dicts, 'matches': live_matches_dicts,
'group_stages': group_stages_dicts, 'group_stages': group_stages_dicts,
'summons': [], 'summons': [],
'rankings' : []
} }
def broadcasted_matches_and_group_stages(self): def broadcasted_matches_and_group_stages(self):
@ -479,19 +491,26 @@ class Tournament(models.Model):
matches.extend(first_round.get_matches_recursive(True)) matches.extend(first_round.get_matches_recursive(True))
else: else:
current_round = self.round_to_show() current_round = self.round_to_show()
print("current_round", current_round)
if current_round: if current_round:
# Add full matches from the next rounds # Add full matches from the next rounds
print("Add full matches from the next rounds")
next_round = self.round_for_index(current_round.index - 1) next_round = self.round_for_index(current_round.index - 1)
if next_round: if next_round:
print("next_round", next_round)
matches.extend(next_round.get_matches_recursive(True)) matches.extend(next_round.get_matches_recursive(True))
# Add matches from the previous round or group_stages # Add matches from the previous round or group_stages
print("Add matches from the previous round or group_stages")
previous_round = self.round_for_index(current_round.index + 1) previous_round = self.round_for_index(current_round.index + 1)
if previous_round: if previous_round:
print("previous_round", previous_round)
print('test 1')
matches.extend(current_round.get_matches_recursive(True)) matches.extend(current_round.get_matches_recursive(True))
matches.extend(previous_round.get_matches_recursive(True)) matches.extend(previous_round.get_matches_recursive(True))
else: else:
print("else")
matches.extend(current_round.all_matches(True)) matches.extend(current_round.all_matches(True))
group_stages = self.live_group_stages() group_stages = self.live_group_stages()

@ -22,19 +22,6 @@ body {
box-shadow: 0 0 0px 0px #fbead6; box-shadow: 0 0 0px 0px #fbead6;
} }
.headerbubble {
padding: 20px;
background-color: white;
border-radius: 24px;
box-shadow: 0 0 0px 0px #fbead6;
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 120%; /* Allow bubble to take full width */
box-sizing: border-box; /* Include padding in the width calculation */
}
.bold { .bold {
font-family: "Montserrat-Bold"; font-family: "Montserrat-Bold";
} }

@ -36,6 +36,7 @@
paginatedMatches: null, paginatedMatches: null,
paginatedGroupStages: null, paginatedGroupStages: null,
paginatedSummons: null, paginatedSummons: null,
paginatedRankings: null,
active: 1, active: 1,
prefixTitle: '', prefixTitle: '',
retrieveData() { retrieveData() {
@ -45,11 +46,33 @@
this.paginatedMatches = this.paginate(data.matches, 8) this.paginatedMatches = this.paginate(data.matches, 8)
this.paginatedGroupStages = this.paginate(data.group_stages, 4) this.paginatedGroupStages = this.paginate(data.group_stages, 4)
this.paginatedSummons = this.paginateSummons(data.summons) this.paginatedSummons = this.paginateSummons(data.summons)
this.paginatedRankings = this.paginateRankings(data.rankings)
this.setPrefixTitle() this.setPrefixTitle()
// Adjust active if it exceeds the new page count
if (this.active > this.pageCount()) {
this.active = 1; // Reset to the first page
}
}) })
}, },
paginateSummons(array) { paginateSummons(array) {
let pageSize = 20 let pageSize = 16
pages = this.paginate(array, pageSize)
const splitGroups = []
pages.forEach(group => {
const firstHalf = group.slice(0, pageSize / 2)
const secondHalf = group.slice(pageSize / 2)
if (secondHalf.length > 0) {
splitGroups.push([firstHalf, secondHalf])
} else {
splitGroups.push([firstHalf])
}
});
return splitGroups
},
paginateRankings(array) {
let pageSize = 16
pages = this.paginate(array, pageSize) pages = this.paginate(array, pageSize)
const splitGroups = [] const splitGroups = []
@ -80,46 +103,39 @@
}, 15000) }, 15000)
}, },
pageCount() { pageCount() {
return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length + this.paginatedRankings.length
}, },
setPrefixTitle() { setPrefixTitle() {
if (this.active < 1 + this.paginatedSummons.length) { if (this.active < 1 + this.paginatedSummons.length) {
this.prefixTitle = 'Convocations' this.prefixTitle = 'Convocations'
} else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) { } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) {
this.prefixTitle = 'Matchs' this.prefixTitle = 'Matchs'
} else { } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) {
this.prefixTitle = 'Poules' this.prefixTitle = 'Poules'
} else {
this.prefixTitle = 'Classement'
} }
} }
}" x-init="loop()"> }" x-init="loop()">
<header>
<div class="wrapper"> <div id="header">
<header> <div class="left-content bubble">
<div class="grid-x"> <img src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" alt="logo" class="logo">
<div class="cell medium-6 large-6 topblock my-block"> <div class="left-margin">
<div class="left-content bubble"> <h1 class="club">{{ tournament.broadcast_event_display_name }}</h1>
<img <h1 class="event"><span x-text="prefixTitle"></span> {{ tournament.broadcast_display_name }}</h1>
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" </div >
class="logo inline"
/>
<div class="inline">
<h1 class="club">{{ tournament.broadcast_event_display_name }}</h1>
<h1 class="event"><span x-text="prefixTitle"></span> {{ tournament.broadcast_display_name }}</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="right">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div> </div>
</header> {% if qr_code_options %}
<div class="right-content">{% qr_from_text qr_code_url options=qr_code_options %}</div>
{% endif %}
</div>
</header>
<main>
<div class="wrapper">
<main>
<div class="grid-x"> <div class="grid-x">
<template x-for="i in paginatedSummons.length"> <template x-for="i in paginatedSummons.length">
@ -146,6 +162,13 @@
</template> </template>
</template> </template>
<template x-for="i in paginatedRankings.length">
<template x-for="column in paginatedRankings[i-1]">
<div class="cell medium-6 large-6 topblock my-block" x-show="active === i + paginatedSummons.length + paginatedMatches.length + paginatedGroupStages.length">
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
</div>
</template>
</template>
</div> </div>
</main> </main>

@ -1,20 +1,22 @@
{% load static %} <div class="bubble">
<template x-for="(ranking, index) in column" >
<div>
<div class="table-row-3-colums-ranks">
<div> <div class="table-cell"><div class="mybox center"><span x-text="ranking.formatted_ranking"></div></div>
<div class="table-row-3-colums-ranks"> <div class="table-cell table-cell-large padding-left semibold">
<div class="table-cell"><div class="mybox center"><span x-text="ranking.formatted_ranking"></div></div> <template x-for="name in ranking.names" >
<div class="table-cell table-cell-large padding-left semibold"> <div><span x-text="name"></div>
</template>
<template x-for="name in ranking.names" > </div>
<div><span x-text="name"></div> {% if tournament.display_points_earned %}
</template> <div class="table-cell right horizontal-padding numbers"><span x-text="ranking.points"></div>
{% endif %}
</div>
<div x-show="index < column.length - 1">
<hr/>
</div>
</div> </div>
{% if tournament.display_points_earned %} </template>
<div class="table-cell right horizontal-padding numbers"><span x-text="ranking.points"></div>
{% endif %}
</div>
<div x-show="index < column.length - 1">
<hr/>
</div>
</div> </div>

@ -54,14 +54,7 @@
<template x-for="i in paginatedRankings.length" > <template x-for="i in paginatedRankings.length" >
<template x-for="column in paginatedRankings[i-1]" > <template x-for="column in paginatedRankings[i-1]" >
<div class="cell medium-6 large-6 topblock my-block" x-show="active === i"> <div class="cell medium-6 large-6 topblock my-block" x-show="active === i">
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
<div class="bubble">
<template x-for="(ranking, index) in column" >
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
</template>
</div>
</div> </div>
</template> </template>
</template> </template>

Loading…
Cancel
Save