mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 05:42:23 +00:00
Display pools table
This commit is contained in:
parent
170326d503
commit
4faec03efb
@ -307,7 +307,10 @@ class Pool(models.Model):
|
|||||||
return Solution.objects.filter(participation__in=self.participations, final_solution=self.tournament.final)
|
return Solution.objects.filter(participation__in=self.participations, final_solution=self.tournament.final)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self)
|
return _("Pool {round} for tournament {tournament} with teams {teams}")\
|
||||||
|
.format(round=self.round,
|
||||||
|
tournament=str(self.tournament),
|
||||||
|
teams=", ".join(participation.team.trigram for participation in self.participations.all()))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("pool")
|
verbose_name = _("pool")
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
# Copyright (C) 2020 by Animath
|
# Copyright (C) 2020 by Animath
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
from django.utils.text import format_lazy
|
from django.utils.text import format_lazy
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
|
||||||
from .models import Team, Tournament
|
from .models import Pool, Team, Tournament
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
@ -74,3 +75,23 @@ class TournamentTable(tables.Table):
|
|||||||
model = Tournament
|
model = Tournament
|
||||||
fields = ('name', 'date',)
|
fields = ('name', 'date',)
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
|
||||||
|
|
||||||
|
class PoolTable(tables.Table):
|
||||||
|
teams = tables.LinkColumn(
|
||||||
|
'participation:pool_detail',
|
||||||
|
args=[tables.A('id')],
|
||||||
|
verbose_name=_("teams"),
|
||||||
|
accessor=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
def render_teams(self, record):
|
||||||
|
return ", ".join(participation.team.trigram for participation in record.participations.all())
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table condensed table-striped',
|
||||||
|
}
|
||||||
|
model = Pool
|
||||||
|
fields = ('teams', 'round', 'tournament',)
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
@ -24,6 +24,15 @@
|
|||||||
{% trans "No solution was uploaded yet." %}
|
{% trans "No solution was uploaded yet." %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
{% if participation.pools.all %}
|
||||||
|
<dt class="col-sm-2">{% trans "Pools:" %}</dt>
|
||||||
|
<dd class="col-sm-10">
|
||||||
|
{% for pool in participation.pools.all %}
|
||||||
|
<a href="{{ pool.get_absolute_url }}" data-turbolinks="false">{{ pool }}{% if not forloop.last %}, {% endif %}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-center">
|
<div class="card-footer text-center">
|
||||||
|
@ -60,4 +60,15 @@
|
|||||||
<div id="teams_table">
|
<div id="teams_table">
|
||||||
{% render_table teams %}
|
{% render_table teams %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h3>{% trans "Pools" %}</h3>
|
||||||
|
<div id="pools_table">
|
||||||
|
{% render_table pools %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if user.registration.is_admin %}
|
||||||
|
<a class="btn btn-block btn-success" href="#">{% trans "Add new pool" %}</a>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -26,7 +26,7 @@ from tfjm.views import AdminMixin
|
|||||||
from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, SolutionForm, TeamForm, TournamentForm, \
|
from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, SolutionForm, TeamForm, TournamentForm, \
|
||||||
ValidateParticipationForm
|
ValidateParticipationForm
|
||||||
from .models import Participation, Team, Tournament, Solution
|
from .models import Participation, Team, Tournament, Solution
|
||||||
from .tables import TeamTable, TournamentTable, ParticipationTable
|
from .tables import TeamTable, TournamentTable, ParticipationTable, PoolTable
|
||||||
|
|
||||||
|
|
||||||
class CreateTeamView(LoginRequiredMixin, CreateView):
|
class CreateTeamView(LoginRequiredMixin, CreateView):
|
||||||
@ -434,6 +434,7 @@ class TournamentDetailView(DetailView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["teams"] = ParticipationTable(self.object.participations.all())
|
context["teams"] = ParticipationTable(self.object.participations.all())
|
||||||
|
context["pools"] = PoolTable(self.object.pools.all())
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user