fix bracket

shop
Raz 8 months ago
parent 6272e11f21
commit 862fca2b2c
  1. 22
      tournaments/models/tournament.py
  2. 4
      tournaments/static/tournaments/css/broadcast.css
  3. 4
      tournaments/static/tournaments/css/style.css
  4. 18
      tournaments/templates/tournaments/tournament_bracket.html

@ -840,7 +840,7 @@ class Tournament(models.Model):
if self.end_date is not None: if self.end_date is not None:
return is_build_and_not_empty return is_build_and_not_empty
if timezone.now() >= timezone.localtime(self.start_date): if timezone.now() >= self.local_start_date():
return is_build_and_not_empty return is_build_and_not_empty
minimum_publish_date = self.creation_date.replace(hour=9, minute=0) + timedelta(days=1) minimum_publish_date = self.creation_date.replace(hour=9, minute=0) + timedelta(days=1)
return timezone.now() >= timezone.localtime(minimum_publish_date) return timezone.now() >= timezone.localtime(minimum_publish_date)
@ -850,7 +850,7 @@ class Tournament(models.Model):
return self.has_team_registrations() return self.has_team_registrations()
if self.publish_teams: if self.publish_teams:
return self.has_team_registrations() return self.has_team_registrations()
if timezone.now().date() >= self.start_date.date(): if timezone.now() >= self.local_start_date():
return self.has_team_registrations() return self.has_team_registrations()
return False return False
@ -862,7 +862,7 @@ class Tournament(models.Model):
return False return False
if self.publish_summons: if self.publish_summons:
return self.has_summons() return self.has_summons()
if timezone.now() >= self.start_date: if timezone.now() >= self.local_start_date():
return self.has_summons() return self.has_summons()
return False return False
@ -876,7 +876,7 @@ class Tournament(models.Model):
first_group_stage_start_date = self.group_stage_start_date() first_group_stage_start_date = self.group_stage_start_date()
if first_group_stage_start_date is None: if first_group_stage_start_date is None:
return timezone.now() >= self.start_date return timezone.now() >= self.local_start_date()
else: else:
return timezone.now() >= first_group_stage_start_date return timezone.now() >= first_group_stage_start_date
@ -885,7 +885,8 @@ class Tournament(models.Model):
if len(group_stages) == 0: if len(group_stages) == 0:
return None return None
return min(group_stages, key=lambda gs: gs.start_date).start_date timezone = self.timezone()
return min(group_stages, key=lambda gs: gs.start_date).start_date.astimezone(timezone)
def display_matches(self): def display_matches(self):
if self.end_date is not None: if self.end_date is not None:
@ -898,12 +899,12 @@ class Tournament(models.Model):
first_match_start_date = self.first_match_start_date(bracket_matches) first_match_start_date = self.first_match_start_date(bracket_matches)
if first_match_start_date is None: if first_match_start_date is None:
return timezone.now() >= self.start_date return timezone.now() >= self.local_start_date()
bracket_start_date = self.getEightAm(first_match_start_date) bracket_start_date = self.getEightAm(first_match_start_date)
if bracket_start_date < self.start_date: if bracket_start_date < self.local_start_date():
bracket_start_date = self.start_date bracket_start_date = self.local_start_date()
group_stage_start_date = self.group_stage_start_date() group_stage_start_date = self.group_stage_start_date()
if group_stage_start_date is not None: if group_stage_start_date is not None:
@ -926,8 +927,7 @@ class Tournament(models.Model):
matches = [m for m in bracket_matches if m.start_date is not None] matches = [m for m in bracket_matches if m.start_date is not None]
if len(matches) == 0: if len(matches) == 0:
return None return None
return min(matches, key=lambda m: m.start_date).local_start_date()
return min(matches, key=lambda m: m.start_date).start_date
def getEightAm(self, date): def getEightAm(self, date):
return date.replace(hour=8, minute=0, second=0, microsecond=0, tzinfo=date.tzinfo) return date.replace(hour=8, minute=0, second=0, microsecond=0, tzinfo=date.tzinfo)
@ -963,7 +963,7 @@ class Tournament(models.Model):
if self.end_date is not None: if self.end_date is not None:
return True return True
timezoned_datetime = timezone.localtime(self.start_date) timezoned_datetime = self.local_start_date()
end = timezoned_datetime + timedelta(days=self.day_duration + 1) end = timezoned_datetime + timedelta(days=self.day_duration + 1)
now = timezone.now() now = timezone.now()
return now >= end and self.is_build_and_not_empty() and self.nearly_over() return now >= end and self.is_build_and_not_empty() and self.nearly_over()

@ -31,7 +31,7 @@ body {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 2.8em; /* This ensures minimum height for 2 lines */ min-height: 3.2em; /* This ensures minimum height for 2 lines */
justify-content: center; justify-content: center;
overflow: hidden; overflow: hidden;
} }
@ -43,7 +43,6 @@ body {
/* For single player teams */ /* For single player teams */
.player.single-player .bold { .player.single-player .bold {
max-height: 2.8em; /* Adjust based on your needs */
line-height: 1.4em; line-height: 1.4em;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
@ -52,6 +51,7 @@ body {
/* For two player teams */ /* For two player teams */
.player.two-players .bold { .player.two-players .bold {
line-height: 1.4em;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

@ -327,7 +327,7 @@ tr {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 2.8em; /* This ensures minimum height for 2 lines */ min-height: 3.2em; /* This ensures minimum height for 2 lines */
justify-content: center; justify-content: center;
overflow: hidden; overflow: hidden;
} }
@ -339,7 +339,6 @@ tr {
/* For single player teams */ /* For single player teams */
.player.single-player .semibold { .player.single-player .semibold {
max-height: 2.8em; /* Adjust based on your needs */
line-height: 1.4em; line-height: 1.4em;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
@ -348,6 +347,7 @@ tr {
/* For two player teams */ /* For two player teams */
.player.two-players .semibold { .player.two-players .semibold {
line-height: 1.4em;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

@ -59,12 +59,12 @@ function renderBracket() {
const finalRoundIndex = (roundCount - 1) / 2; const finalRoundIndex = (roundCount - 1) / 2;
let nextMatchDistance = baseDistance; let nextMatchDistance = baseDistance;
let minimumMatchDistance = 1; let minimumMatchDistance = 1;
if (rounds[0].length <= 2) {
minimumMatchDistance = 2
nextMatchDistance = baseDistance * 2;
}
rounds.forEach((roundMatches, roundIndex) => { rounds.forEach((roundMatches, roundIndex) => {
if (rounds[0].length <= 2) {
minimumMatchDistance = 2
nextMatchDistance = baseDistance * 2;
}
const roundDiv = document.createElement('div'); const roundDiv = document.createElement('div');
roundDiv.className = 'butterfly-round'; roundDiv.className = 'butterfly-round';
roundDiv.style.setProperty('--match-width', `${365}px`); roundDiv.style.setProperty('--match-width', `${365}px`);
@ -172,7 +172,7 @@ function renderBracket() {
} }
} }
if (roundIndex >= finalRoundIndex - 1) { if (roundIndex >= finalRoundIndex - 2) {
if (roundCount > 5) { if (roundCount > 5) {
if (roundIndex == finalRoundIndex - 1) { if (roundIndex == finalRoundIndex - 1) {
matchDiv.classList.add('inward'); matchDiv.classList.add('inward');
@ -180,14 +180,14 @@ function renderBracket() {
if (roundIndex == finalRoundIndex + 1) { if (roundIndex == finalRoundIndex + 1) {
matchDiv.classList.add('outward'); matchDiv.classList.add('outward');
} }
if (roundIndex === finalRoundIndex - 2 || roundIndex === finalRoundIndex + 2) {
nextMatchDistance = nextMatchDistance - baseDistance;
}
} }
} }
if (roundIndex === finalRoundIndex - 2 || roundIndex === finalRoundIndex + 2) { if (roundIndex == finalRoundIndex - 1 || roundIndex == finalRoundIndex + 1) {
nextMatchDistance = nextMatchDistance - baseDistance;
}
else if (roundIndex == finalRoundIndex - 1 || roundIndex == finalRoundIndex + 1) {
nextMatchDistance = baseDistance; nextMatchDistance = baseDistance;
} }

Loading…
Cancel
Save