From 70050827d8b91ccd0b1b1dc56b37627c44f33fb9 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 19 May 2024 21:02:44 +0200 Subject: [PATCH] Better bold lines in tfjm.org export Signed-off-by: Emmy D'Anello --- .../management/commands/export_results.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/participation/management/commands/export_results.py b/participation/management/commands/export_results.py index a86340a..55ee898 100644 --- a/participation/management/commands/export_results.py +++ b/participation/management/commands/export_results.py @@ -17,8 +17,8 @@ class Command(BaseCommand): self.w("") self.w("") - def w(self, msg): - self.stdout.write(msg) + def w(self, msg, prefix="", suffix=""): + self.stdout.write(f"{prefix}{msg}{suffix}") def handle_tournament(self, tournament): name = tournament.name @@ -64,17 +64,16 @@ class Command(BaseCommand): self.w("") bold = (not tournament.final and participation.final) or (tournament.final and i < 2) if bold: - self.w(f"\t{participation.team.name} ({participation.team.trigram})") + prefix, suffix = "\t", "" else: - self.w(f"\t{participation.team.name} ({participation.team.trigram})") + prefix, suffix = "\t", "" + self.w(f"{participation.team.name} ({participation.team.trigram})", prefix, suffix) for pool in tournament.pools.filter(participations=participation).all(): pool_note = pool.average(participation) - self.w(f"\t{pool_note:.01f}") - self.w(f"\t{note:.01f}") + self.w(f"{pool_note:.01f}", prefix, suffix) + self.w(f"{note:.01f}", prefix, suffix) if tournament.final: - self.w(f"\t{participation.mention_final}") - else: - self.w(f"\t{participation.mention}") + self.w(participation.mention_final if tournament.final else participation.mention, prefix, suffix) self.w("") self.w("") self.w("")