From c7b42f8cc9ea7af6228dba88bf0e280444b97421 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 13 Jun 2024 10:03:05 +0200 Subject: [PATCH] attempt to fix sorting --- tournaments/models/match.py | 10 +++++----- tournaments/models/tournament.py | 4 +++- tournaments/templates/tournaments/broadcast_club.html | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index fe93234..85b88b6 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -166,11 +166,11 @@ class Match(models.Model): else: return self.team_scores.order_by('team_registration__bracket_position') - def sort_start_date(self): - if self.start_date: - return self.start_date - else: - return timezone.now() + timedelta(days=7) + # def non_null_start_date(self): + # if self.start_date: + # return self.start_date + # else: + # return timezone.now() + timedelta(days=7) # def sort_value(self): # sort_score = 0 diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 68c9509..c1434a5 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -457,7 +457,9 @@ class Tournament(models.Model): for group_stage in self.groupstage_set.all(): matches.extend(group_stage.match_set.all()) matches = [m for m in matches if m.should_appear()] - matches.sort(key=lambda m: (m.non_null_start_date(), m.index), reverse=True) + # matches.sort(key=lambda m: (m.non_null_start_date(), m.index), reverse=True) + matches.sort(key=lambda m: (m.start_date is None, m.start_date, m.index), reverse=True) + return matches def display_rankings(self): diff --git a/tournaments/templates/tournaments/broadcast_club.html b/tournaments/templates/tournaments/broadcast_club.html index 81b0859..cb3fa68 100644 --- a/tournaments/templates/tournaments/broadcast_club.html +++ b/tournaments/templates/tournaments/broadcast_club.html @@ -32,7 +32,7 @@ Automatic | Matchs | Poules | - Convocations + Convocations | Classement