1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 01:58:23 +02:00

Display the tournament list

This commit is contained in:
Yohann D'ANELLO
2020-12-30 12:13:05 +01:00
parent e2e2c97584
commit 03144ae58e
6 changed files with 54 additions and 6 deletions

View File

@ -129,7 +129,7 @@ class Tournament(models.Model):
)
date_end = models.DateField(
verbose_name=_("start"),
verbose_name=_("end"),
default=timezone.now,
)

View File

@ -1,10 +1,10 @@
# 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
from .models import Team, Tournament
# noinspection PyTypeChecker
@ -54,3 +54,16 @@ class ParticipationTable(tables.Table):
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'

View File

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load django_tables2 i18n %}
{% block contenttitle %}
<h1>{% trans "All tournaments" %}</h1>
{% endblock %}
{% block content %}
<div id="form-content">
{% render_table table %}
{% if user.registration.is_admin %}
<a class="btn btn-block btn-success" href="#">{% trans "Add tournament" %}</a>
{% endif %}
</div>
{% endblock %}

View File

@ -6,7 +6,7 @@ from django.views.generic import TemplateView
from .views import CreateTeamView, JoinTeamView, \
MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, TeamAuthorizationsView, \
TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView
TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, TournamentListView
app_name = "participation"
@ -22,5 +22,6 @@ urlpatterns = [
path("team/leave/", TeamLeaveView.as_view(), name="team_leave"),
path("detail/", MyParticipationDetailView.as_view(), name="my_participation_detail"),
path("detail/<int:pk>/", ParticipationDetailView.as_view(), name="participation_detail"),
path("tournament/", TournamentListView.as_view(), name="tournament_list"),
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
]

View File

@ -24,8 +24,8 @@ from tfjm.matrix import Matrix
from tfjm.views import AdminMixin
from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, TeamForm, ValidateParticipationForm
from .models import Participation, Team
from .tables import TeamTable
from .models import Participation, Team, Tournament
from .tables import TeamTable, TournamentTable
class CreateTeamView(LoginRequiredMixin, CreateView):
@ -401,3 +401,8 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
context["title"] = lambda: _("Participation of team {trigram}").format(trigram=self.object.team.trigram)
return context
class TournamentListView(SingleTableView):
model = Tournament
table_class = TournamentTable