From 52f0d442cddf048db3f06f71ec3ce8895eab646a Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 31 Dec 2020 12:23:09 +0100 Subject: [PATCH] Better date render --- apps/participation/models.py | 3 +++ apps/participation/tables.py | 9 ++++++++- apps/participation/views.py | 9 --------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/participation/models.py b/apps/participation/models.py index 05113b7..43482c2 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -198,6 +198,9 @@ class Tournament(models.Model): return Synthesis.objects.filter(final_solution=True) return Synthesis.objects.filter(participation__tournament=self) + def get_absolute_url(self): + return reverse_lazy("participation:tournament_detail", args=(self.pk,)) + def __str__(self): return repr(self) diff --git a/apps/participation/tables.py b/apps/participation/tables.py index 6e81c34..11d517d 100644 --- a/apps/participation/tables.py +++ b/apps/participation/tables.py @@ -1,5 +1,6 @@ # Copyright (C) 2020 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +from django.utils import formats from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ import django_tables2 as tables @@ -57,8 +58,14 @@ class ParticipationTable(tables.Table): class TournamentTable(tables.Table): + name = tables.LinkColumn() + + date = tables.Column(_("date").capitalize, accessor="id") + def render_date(self, record): - return format_lazy(_("From {start} to {end}"), start=record.start, end=record.end) + return format_lazy(_("From {start} to {end}"), + start=formats.date_format(record.date_start, format="SHORT_DATE_FORMAT", use_l10n=True), + end=formats.date_format(record.date_end, format="SHORT_DATE_FORMAT", use_l10n=True)) class Meta: attrs = { diff --git a/apps/participation/views.py b/apps/participation/views.py index c75d05d..6f00049 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -74,9 +74,6 @@ class CreateTeamView(LoginRequiredMixin, CreateView): f"@{user.registration.matrix_username}:tfjm.org") return ret - def get_success_url(self): - return reverse_lazy("participation:team_detail", args=(self.object.pk,)) - class JoinTeamView(LoginRequiredMixin, FormView): """ @@ -294,9 +291,6 @@ class TeamUpdateView(LoginRequiredMixin, UpdateView): participation_form.save() return super().form_valid(form) - def get_success_url(self): - return reverse_lazy("participation:team_detail", args=(self.object.pk,)) - class TeamAuthorizationsView(LoginRequiredMixin, DetailView): """ @@ -430,9 +424,6 @@ class TournamentUpdateView(AdminMixin, UpdateView): model = Tournament form_class = TournamentForm - def get_success_url(self): - return reverse_lazy("participation:tournament_detail", args=(self.object.pk,)) - class TournamentDetailView(DetailView): """