From 5db36e26c403919cfce197a01b294439f48e7c3a Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 24 Jun 2024 10:08:57 +0200 Subject: [PATCH] Fixing potential crashes --- tournaments/models/match.py | 6 ++++-- tournaments/models/team_score.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index 73a1205..fca8c42 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -151,12 +151,14 @@ class Match(models.Model): for team_score in self.sorted_team_scores(): if team_score.team_registration: image = team_score.team_registration.logo + weight = team_score.team_registration.weight + is_winner = team_score.team_registration.id == self.winning_team_id else: image = None + weight= None + is_winner = False names = team_score.team_names() scores = team_score.scores_array() - weight = team_score.team_registration.weight - is_winner = team_score.team_registration.id == self.winning_team_id walk_out = team_score.walk_out team = Team(image, names, scores, weight, is_winner, walk_out) livematch.add_team(team) diff --git a/tournaments/models/team_score.py b/tournaments/models/team_score.py index 99853e1..73db17e 100644 --- a/tournaments/models/team_score.py +++ b/tournaments/models/team_score.py @@ -22,10 +22,11 @@ class TeamScore(models.Model): def team_names(self): names = [] - if self.team_registration.name: - names.append(self.team_registration.name) - else: - names = self.team_registration.team_names() + if self.team_registration: + if self.team_registration.name: + names.append(self.team_registration.name) + else: + names = self.team_registration.team_names() return names def scores(self):