From bacdd5cfcfb231e10efcec37a9948719086137ac Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Thu, 18 Apr 2024 15:12:45 +0200 Subject: [PATCH] Replace pool name by its short name in severous views Signed-off-by: Emmy D'Anello --- participation/admin.py | 4 ++-- participation/views.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/participation/admin.py b/participation/admin.py index 4345c41..50a319f 100644 --- a/participation/admin.py +++ b/participation/admin.py @@ -135,7 +135,7 @@ class PassageAdmin(admin.ModelAdmin): @admin.display(description=_("pool"), ordering='pool__letter') def pool_abbr(self, record): - return f"{record.pool.get_letter_display()}{record.pool.round}" + return f"{record.pool.short_name}" @admin.display(description=_("tournament"), ordering='pool__tournament__name') def tournament(self, record: Passage): @@ -154,7 +154,7 @@ class NoteAdmin(admin.ModelAdmin): @admin.display(description=_("pool")) def pool(self, record): - return record.passage.pool.get_letter_display() + return record.passage.pool.short_name @admin.register(Solution) diff --git a/participation/views.py b/participation/views.py index 5b1de92..ae3a67a 100644 --- a/participation/views.py +++ b/participation/views.py @@ -1030,7 +1030,7 @@ class SolutionsDownloadView(VolunteerMixin, View): def prefix(s: Solution | Synthesis) -> str: pool = s.pool if is_solution else s.passage.pool - p = f"Poule {pool.get_letter_display()}{pool.round}/" + p = f"Poule {pool.short_name}/" if not is_solution: p += f"Passage {s.passage.position}/" return p @@ -1051,7 +1051,7 @@ class SolutionsDownloadView(VolunteerMixin, View): syntheses = Synthesis.objects.filter(passage__pool=pool).all() filename = _("Solutions for pool {pool} of tournament {tournament}.zip") \ if is_solution else _("Syntheses for pool {pool} of tournament {tournament}.zip") - filename = filename.format(pool=pool.get_letter_display() + str(pool.round), + filename = filename.format(pool=pool.short_name, tournament=pool.tournament.name) def prefix(s: Solution | Synthesis) -> str: @@ -1093,7 +1093,7 @@ class PoolJuryView(VolunteerMixin, FormView, DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['title'] = _("Jury of pool {pool} for {tournament} with teams {teams}") \ - .format(pool=f"{self.object.get_letter_display()}{self.object.round}", + .format(pool=f"{self.object.short_name}", tournament=self.object.tournament.name, teams=", ".join(participation.team.trigram for participation in self.object.participations.all())) return context @@ -1453,7 +1453,7 @@ class PoolNotesTemplateView(VolunteerMixin, DetailView): col_style.addElement(TableColumnProperties(columnwidth="2.6cm", breakbefore="auto")) doc.automaticstyles.addElement(col_style) - table = Table(name=f"Poule {self.object.get_letter_display()}{self.object.round}") + table = Table(name=f"Poule {self.object.short_name}") doc.spreadsheet.addElement(table) table.addElement(TableColumn(stylename=first_col_style)) @@ -1736,7 +1736,7 @@ class PoolNotesTemplateView(VolunteerMixin, DetailView): return FileResponse(streaming_content=open("/tmp/notes.ods", "rb"), content_type="application/vnd.oasis.opendocument.spreadsheet", filename=f"Feuille de notes - {self.object.tournament.name} " - f"- Poule {self.object.get_letter_display()}{self.object.round}.ods") + f"- Poule {self.object.short_name}.ods") class NotationSheetTemplateView(VolunteerMixin, DetailView):