From 1a9a61e171e0a72f4e5e1c8920dbf7150a077677 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 13 Mar 2024 22:48:10 +0100 Subject: [PATCH] Fix summons --- tournaments/models/tournament.py | 1 + .../tournaments/broadcasted_summons.html | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 9061d69..3378b22 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -64,6 +64,7 @@ class Tournament(models.Model): weight = team_registration.weight() summon = TeamSummon(names, next_match.start_date, weight, stage, team_registration.logo) summons.append(summon) + summons.sort(key=lambda s: s.weight) return summons diff --git a/tournaments/templates/tournaments/broadcasted_summons.html b/tournaments/templates/tournaments/broadcasted_summons.html index f4541de..0971001 100644 --- a/tournaments/templates/tournaments/broadcasted_summons.html +++ b/tournaments/templates/tournaments/broadcasted_summons.html @@ -16,7 +16,16 @@ fetch('/tournament/{{ tournament.id }}/summons/json/') .then(res => res.json()) .then((data) => { - this.paginatedMatches = this.paginate(this.paginate(data, 16), 8) + this.paginatedMatches = this.paginate(data, 8) + + const splitGroups = []; + this.paginatedMatches.forEach(group => { + const firstHalf = group.slice(0, group.length / 2); + const secondHalf = group.slice(group.length / 2); + splitGroups.push([firstHalf, secondHalf]); + }); + this.paginatedMatches = splitGroups; + }) }, paginate(array, pageSize) { @@ -39,11 +48,12 @@