mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-26 03:42:22 +00:00
132 lines
3.3 KiB
Python
132 lines
3.3 KiB
Python
import django_tables2 as tables
|
|
from django.urls import reverse_lazy
|
|
from django.utils.translation import gettext as _
|
|
from django_tables2 import A
|
|
|
|
from member.models import Solution, Synthesis
|
|
from .models import Tournament, Team, Pool
|
|
|
|
|
|
class TournamentTable(tables.Table):
|
|
name = tables.LinkColumn(
|
|
"tournament:detail",
|
|
args=[A("pk")],
|
|
)
|
|
|
|
date_start = tables.Column(
|
|
verbose_name=_("dates").capitalize(),
|
|
)
|
|
|
|
def render_date_start(self, record):
|
|
return _("From {start:%b %d %Y} to {end:%b %d %Y}").format(start=record.date_start, end=record.date_end)
|
|
|
|
class Meta:
|
|
model = Tournament
|
|
fields = ("name", "date_start", "date_inscription", "date_solutions", "size", )
|
|
attrs = {
|
|
'class': 'table table-condensed table-striped table-hover'
|
|
}
|
|
|
|
|
|
class TeamTable(tables.Table):
|
|
name = tables.LinkColumn(
|
|
"tournament:team_detail",
|
|
args=[A("pk")],
|
|
)
|
|
|
|
class Meta:
|
|
model = Team
|
|
fields = ("name", "trigram", "validation_status", )
|
|
attrs = {
|
|
'class': 'table table-condensed table-striped table-hover'
|
|
}
|
|
|
|
|
|
class SolutionTable(tables.Table):
|
|
team = tables.LinkColumn(
|
|
"tournament:team_detail",
|
|
args=[A("team.pk")],
|
|
)
|
|
|
|
tournament = tables.LinkColumn(
|
|
"tournament:detail",
|
|
args=[A("tournament.pk")],
|
|
accessor=A("tournament"),
|
|
)
|
|
|
|
file = tables.LinkColumn(
|
|
"document",
|
|
args=[A("file")],
|
|
attrs={
|
|
"a": {
|
|
"data-turbolinks": "false",
|
|
}
|
|
}
|
|
)
|
|
|
|
def render_file(self):
|
|
return _("Download")
|
|
|
|
class Meta:
|
|
model = Solution
|
|
fields = ("team", "tournament", "problem", "uploaded_at", "file", )
|
|
attrs = {
|
|
'class': 'table table-condensed table-striped table-hover'
|
|
}
|
|
|
|
|
|
class SynthesisTable(tables.Table):
|
|
team = tables.LinkColumn(
|
|
"tournament:team_detail",
|
|
args=[A("team.pk")],
|
|
)
|
|
|
|
tournament = tables.LinkColumn(
|
|
"tournament:detail",
|
|
args=[A("tournament.pk")],
|
|
accessor=A("tournament"),
|
|
)
|
|
|
|
file = tables.LinkColumn(
|
|
"document",
|
|
args=[A("file")],
|
|
attrs={
|
|
"a": {
|
|
"data-turbolinks": "false",
|
|
}
|
|
}
|
|
)
|
|
|
|
def render_file(self):
|
|
return _("Download")
|
|
|
|
class Meta:
|
|
model = Synthesis
|
|
fields = ("team", "tournament", "round", "source", "uploaded_at", "file", )
|
|
attrs = {
|
|
'class': 'table table-condensed table-striped table-hover'
|
|
}
|
|
|
|
|
|
class PoolTable(tables.Table):
|
|
def render_teams(self, value):
|
|
return ", ".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", )
|
|
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,)),
|
|
}
|