2020-10-20 11:06:51 +00:00
|
|
|
from django.utils import timezone
|
2020-10-15 18:39:34 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
import django_tables2 as tables
|
|
|
|
|
2020-10-20 11:06:51 +00:00
|
|
|
from .models import Phase, Team
|
|
|
|
|
|
|
|
|
|
|
|
class CalendarTable(tables.Table):
|
|
|
|
class Meta:
|
|
|
|
attrs = {
|
|
|
|
'class': 'table table condensed table-striped',
|
|
|
|
}
|
|
|
|
row_attrs = {
|
|
|
|
'class': lambda record: 'bg-success' if timezone.now() > record.end else
|
2020-10-20 12:21:16 +00:00
|
|
|
'bg-warning' if timezone.now() > record.start else
|
|
|
|
'bg-danger',
|
|
|
|
'data-id': lambda record: str(record.phase_number),
|
2020-10-20 11:06:51 +00:00
|
|
|
}
|
|
|
|
model = Phase
|
|
|
|
fields = ('phase_number', 'description', 'start', 'end',)
|
|
|
|
template_name = 'django_tables2/bootstrap4.html'
|
2020-10-20 12:21:16 +00:00
|
|
|
order_by = ('phase_number',)
|
2020-10-15 18:39:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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 VideoTable(tables.Table):
|
2020-10-19 13:49:53 +00:00
|
|
|
participationname = tables.LinkColumn(
|
2020-10-15 18:39:34 +00:00
|
|
|
'participation:participation_detail',
|
|
|
|
args=[tables.A("participation__pk")],
|
|
|
|
verbose_name=lambda: _("name").capitalize(),
|
|
|
|
)
|
|
|
|
|
2020-10-19 13:49:53 +00:00
|
|
|
def render_participationname(self, record):
|
|
|
|
return record.participation.team.name
|
|
|
|
|
2020-10-15 18:39:34 +00:00
|
|
|
class Meta:
|
|
|
|
attrs = {
|
|
|
|
'class': 'table table condensed table-striped',
|
|
|
|
}
|
|
|
|
model = Team
|
2020-10-19 13:49:53 +00:00
|
|
|
fields = ('participationname', 'link',)
|
2020-10-15 18:39:34 +00:00
|
|
|
template_name = 'django_tables2/bootstrap4.html'
|