plateforme-tfjm2/apps/tournament/tables.py

41 lines
1.0 KiB
Python
Raw Normal View History

2020-04-29 14:26:52 +00:00
import django_tables2 as tables
from django.utils.translation import gettext as _
2020-04-29 14:59:59 +00:00
from django_tables2 import A
2020-04-29 14:26:52 +00:00
2020-04-29 14:59:59 +00:00
from .models import Tournament, Team
2020-04-29 14:26:52 +00:00
class TournamentTable(tables.Table):
2020-04-29 14:59:59 +00:00
name = tables.LinkColumn(
"tournament:detail",
args=[A("pk")],
)
2020-04-29 14:26:52 +00:00
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'
}
2020-04-29 14:59:59 +00:00
class TeamTable(tables.Table):
2020-04-29 15:58:11 +00:00
name = tables.LinkColumn(
"tournament:team_detail",
args=[A("pk")],
)
2020-04-29 14:59:59 +00:00
class Meta:
model = Team
fields = ("name", "trigram", "validation_status", )
attrs = {
'class': 'table table-condensed table-striped table-hover'
}