70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
# Copyright (C) 2020 by Animath
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
from django.utils.text import format_lazy
|
|
from django.utils.translation import gettext_lazy as _
|
|
import django_tables2 as tables
|
|
|
|
from .models import Team, Tournament
|
|
|
|
|
|
# noinspection PyTypeChecker
|
|
class TeamTable(tables.Table):
|
|
name = tables.LinkColumn(
|
|
'participation:team_detail',
|
|
args=[tables.A("id")],
|
|
verbose_name=lambda: _("name").capitalize(),
|
|
)
|
|
|
|
problem = tables.Column(
|
|
accessor="participation__problem",
|
|
verbose_name=lambda: _("problem number").capitalize(),
|
|
)
|
|
|
|
class Meta:
|
|
attrs = {
|
|
'class': 'table table condensed table-striped',
|
|
}
|
|
model = Team
|
|
fields = ('name', 'trigram', 'problem',)
|
|
template_name = 'django_tables2/bootstrap4.html'
|
|
|
|
|
|
# noinspection PyTypeChecker
|
|
class ParticipationTable(tables.Table):
|
|
name = tables.LinkColumn(
|
|
'participation:participation_detail',
|
|
args=[tables.A("id")],
|
|
verbose_name=lambda: _("name").capitalize(),
|
|
accessor="team__name",
|
|
)
|
|
|
|
trigram = tables.Column(
|
|
verbose_name=lambda: _("trigram").capitalize(),
|
|
accessor="team__trigram",
|
|
)
|
|
|
|
problem = tables.Column(
|
|
verbose_name=lambda: _("problem number").capitalize(),
|
|
)
|
|
|
|
class Meta:
|
|
attrs = {
|
|
'class': 'table table condensed table-striped',
|
|
}
|
|
model = Team
|
|
fields = ('name', 'trigram', 'problem',)
|
|
template_name = 'django_tables2/bootstrap4.html'
|
|
|
|
|
|
class TournamentTable(tables.Table):
|
|
def render_date(self, record):
|
|
return format_lazy(_("From {start} to {end}"), start=record.start, end=record.end)
|
|
|
|
class Meta:
|
|
attrs = {
|
|
'class': 'table table condensed table-striped',
|
|
}
|
|
model = Tournament
|
|
fields = ('name', 'date',)
|
|
template_name = 'django_tables2/bootstrap4.html'
|