import django_tables2 as tables from django.utils.translation import gettext as _ from django_tables2 import A from .models import Tournament, Team 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): file = tables.LinkColumn( "document", args=[A("file")], attrs={ "a": { "data-turbolinks": "false", } } ) def render_file(self): return _("Download") class Meta: model = Team fields = ("team", "team.tournament", "problem", "uploaded_at", "file", ) attrs = { 'class': 'table table-condensed table-striped table-hover' }