1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:02:22 +00:00

Fix table ordering bug

This commit is contained in:
Yohann D'ANELLO 2020-05-06 14:39:03 +02:00
parent c51bdd0d1a
commit 1a83aa0388
2 changed files with 19 additions and 25 deletions

View File

@ -1,5 +1,6 @@
import django_tables2 as tables
from django.urls import reverse_lazy
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from django_tables2 import A
@ -54,7 +55,8 @@ class SolutionTable(tables.Table):
"tournament:detail",
args=[A("tournament.pk")],
accessor=A("tournament"),
verbose_name=_("tournament"),
order_by=("team__tournament__date_start", "team__tournament__name",),
verbose_name=_("Tournament"),
)
file = tables.LinkColumn(
@ -88,6 +90,7 @@ class SynthesisTable(tables.Table):
"tournament:detail",
args=[A("tournament.pk")],
accessor=A("tournament"),
order_by=("team__tournament__date_start", "team__tournament__name",),
verbose_name=_("tournament"),
)
@ -113,27 +116,29 @@ class SynthesisTable(tables.Table):
class PoolTable(tables.Table):
problems = tables.Column(verbose_name=_("Problems"))
problems = tables.Column(
verbose_name=_("Problems"),
orderable=False,
)
tournament = tables.Column(verbose_name=_("Tournament"))
tournament = tables.LinkColumn(
"tournament:detail",
args=[A("tournament.pk")],
verbose_name=_("Tournament"),
order_by=("teams__tournament__date_start", "teams__tournament__name",),
)
def render_teams(self, value):
return ", ".join(team.trigram for team in value.all())
def render_teams(self, record, value):
return format_html('<a href="{url}">{trigrams}</a>',
url=reverse_lazy('tournament:pool_detail', args=(record.pk,)),
trigrams=", ".join(team.trigram for team in value.all()))
def render_problems(self, value):
return ", ".join([str(pb) for pb in value])
def render_juries(self, value):
return ", ".join(str(jury) for jury in value.all())
class Meta:
model = Pool
fields = ("teams", "tournament", "problems", "round", "juries", )
fields = ("teams", "tournament", "problems", "round", )
attrs = {
'class': 'table table-condensed table-striped table-hover'
}
row_attrs = {
'style': 'cursor: pointer;',
'class': 'row-control',
'data-href': lambda record: reverse_lazy('tournament:pool_detail', args=(record.pk,)),
}

View File

@ -10,14 +10,3 @@
<a href="{% url "tournament:create_pool" %}"><button class="btn btn-secondary btn-block">{% trans "Add pool" %}</button></a>
{% endif %}
{% endblock %}
{% block extrajavascript %}
<script>
$(document).ready(function() {
$(".row-control").click(function() {
location.href = $(this).data("href");
});
});
</script>
{% endblock %}