1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 12:38:26 +02:00

Add letter in pool display

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-03-31 17:23:40 +02:00
parent 14505260ff
commit 0fa76d6f25
8 changed files with 168 additions and 99 deletions

View File

@ -170,7 +170,7 @@ class SolutionForm(forms.ModelForm):
class PoolForm(forms.ModelForm):
class Meta:
model = Pool
fields = ('tournament', 'round', 'bbb_url', 'results_available', 'juries',)
fields = ('tournament', 'round', 'letter', 'bbb_url', 'results_available', 'juries',)
widgets = {
"juries": forms.SelectMultiple(attrs={
'class': 'selectpicker',

View File

@ -0,0 +1,30 @@
# Generated by Django 4.1.7 on 2023-03-31 15:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("participation", "0003_alter_team_trigram"),
]
operations = [
migrations.AlterModelOptions(
name="pool",
options={
"ordering": ("round", "letter"),
"verbose_name": "pool",
"verbose_name_plural": "pools",
},
),
migrations.AddField(
model_name="pool",
name="letter",
field=models.PositiveSmallIntegerField(
choices=[(1, "A"), (2, "B"), (3, "C"), (4, "D")],
default=1,
verbose_name="letter",
),
preserve_default=False,
),
]

View File

@ -359,6 +359,16 @@ class Pool(models.Model):
]
)
letter = models.PositiveSmallIntegerField(
choices=[
(1, 'A'),
(2, 'B'),
(3, 'C'),
(4, 'D'),
],
verbose_name=_('letter'),
)
participations = models.ManyToManyField(
Participation,
related_name="pools",
@ -406,6 +416,7 @@ class Pool(models.Model):
class Meta:
verbose_name = _("pool")
verbose_name_plural = _("pools")
ordering = ('round', 'letter',)
class Passage(models.Model):

View File

@ -76,13 +76,20 @@ class TournamentTable(tables.Table):
class PoolTable(tables.Table):
teams = tables.LinkColumn(
letter = tables.LinkColumn(
'participation:pool_detail',
args=[tables.A('id')],
verbose_name=_("pool").capitalize,
)
teams = tables.Column(
verbose_name=_("teams").capitalize,
empty_values=(),
)
def render_letter(self, record):
return format_lazy(_("Pool {letter}{round}"), letter=record.get_letter_display(), round=record.round)
def render_teams(self, record):
return ", ".join(participation.team.trigram for participation in record.participations.all()) \
or _("No defined team")
@ -92,7 +99,7 @@ class PoolTable(tables.Table):
'class': 'table table-condensed table-striped',
}
model = Pool
fields = ('teams', 'round', 'tournament',)
fields = ('letter', 'teams', 'round', 'tournament',)
class PassageTable(tables.Table):

View File

@ -15,6 +15,9 @@
<dt class="col-sm-3">{% trans "Round:" %}</dt>
<dd class="col-sm-9">{{ pool.get_round_display }}</dd>
<dt class="col-sm-3">{% trans "Letter:" %}</dt>
<dd class="col-sm-9">{{ pool.get_letter_display }}</dd>
<dt class="col-sm-3">{% trans "Teams:" %}</dt>
<dd class="col-sm-9">
{% for participation in pool.participations.all %}