Skip to content

Commit b175509

Browse files
authored
feat: add option to abbreviate names in public views (#1027)
1 parent fe5b070 commit b175509

File tree

7 files changed

+55
-5
lines changed

7 files changed

+55
-5
lines changed

bullet/bullet_admin/templates/bullet_admin/results/announce.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@
2828
<div class="text-5xl font-bold mb-6">{{ team.name }}</div>
2929
{% endif %}
3030

31-
<div class="text-3xl">{{ team.contestants_names }}</div>
31+
<div class="text-3xl">
32+
{% if team.venue.abbreviate_names %}
33+
{{ team.abbreviated_names }}
34+
{% else %}
35+
{{ team.contestants_names }}
36+
{% endif %}
37+
</div>
3238
<div class="flex justify-center">{% squares result_row big=True %}</div>
3339
<div class="text-4xl mt-4">{{ result_row.solved_count }}</div>
3440
{% endif %}

bullet/competitions/factories/venues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ class Meta:
2424
"random_elements", elements=[x[0] for x in settings.LANGUAGES]
2525
)
2626
results_announced = factory.Faker("boolean")
27-
participants_hidden = factory.Faker("boolean")
27+
abbreviate_names = factory.Faker("boolean")
2828
email = factory.Faker("email")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.2.7 on 2025-10-14 19:13
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("competitions", "0035_auto_20250123_1932"),
9+
]
10+
11+
operations = [
12+
migrations.RenameField(
13+
model_name="venue",
14+
old_name="participants_hidden",
15+
new_name="abbreviate_names",
16+
),
17+
]

bullet/competitions/models/venues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class RegistrationFlowType(models.IntegerChoices):
106106
accepted_languages = ChoiceArrayField(LanguageField())
107107
local_start = models.DateTimeField(null=True, blank=True)
108108
results_announced = models.BooleanField(default=False) # unused
109-
participants_hidden = models.BooleanField(default=False) # unused
109+
abbreviate_names = models.BooleanField(default=False)
110110

111111
is_online = models.BooleanField(default=False)
112112
is_isolated = models.BooleanField(default=False)

bullet/competitions/templates/teams/list.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ <h2 class="font-bold text-2xl" id="{{ v.venue.shortcode }}">
6666
{% for team in v.teams %}
6767
<div>
6868
{% inline_team_name team %}
69-
<div class="text-xs mt-0.5 text-gray-500">{{ team.contestants.all|join:", " }}</div>
69+
<div class="text-xs mt-0.5 text-gray-500">
70+
{% if v.venue.abbreviate_names %}
71+
{{ team.abbreviated_names }}
72+
{% else %}
73+
{{ team.contestants_names }}
74+
{% endif %}
75+
</div>
7076
</div>
7177
{% endfor %}
7278
</div>

bullet/problems/templates/problems/results/table.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
{% endif %}
4343

4444
{% if not hide_contestants %}
45-
<div class="mt-0.5 text-xs leading-4 text-gray-500">{{ row.team.contestants.all|join:", " }}</div>
45+
<div class="mt-0.5 text-xs leading-4 text-gray-500">
46+
{% if row.team.venue.abbreviate_names %}
47+
{{ row.team.abbreviated_names }}
48+
{% else %}
49+
{{ row.team.contestants_names }}
50+
{% endif %}
51+
</div>
4652
{% endif %}
4753
</td>
4854
<td class="p-2 hidden md:table-cell text-lg">

bullet/users/models/contestants.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ def contact_phone_pretty(self):
150150
def contestants_names(self):
151151
return ", ".join([c.full_name for c in self.contestants.all()])
152152

153+
@property
154+
def abbreviated_names(self):
155+
return ", ".join([c.abbreviated_name for c in self.contestants.all()])
156+
153157
@property
154158
def id_display(self):
155159
return f"#{self.id:06d}"
@@ -248,6 +252,7 @@ def to_export(self, str_only: bool = False):
248252
"contestants": self.contestants_names
249253
if str_only
250254
else [c.full_name for c in self.contestants.all()],
255+
"abbreviated_contestants": self.abbreviated_names,
251256
"online_password": self.online_password,
252257
"rank_venue": self.rank_venue or "",
253258
"rank_country": self.rank_country or "",
@@ -280,6 +285,16 @@ def __str__(self):
280285
name += f" ({self.grade.name})"
281286
return name
282287

288+
@property
289+
def abbreviated_name(self):
290+
parts = self.full_name.split()
291+
if not parts:
292+
return ""
293+
if len(parts) == 1:
294+
return parts[0]
295+
296+
return f"{parts[0]} {parts[-1][0]}."
297+
283298

284299
def get_spanish_upload(instance, filename):
285300
name, ext = os.path.splitext(filename)

0 commit comments

Comments
 (0)