1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 18:22:24 +00:00

Better date render

This commit is contained in:
Yohann D'ANELLO 2020-12-31 12:23:09 +01:00
parent 4e29b4830a
commit 52f0d442cd
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 11 additions and 10 deletions

View File

@ -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)

View File

@ -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 = {

View File

@ -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):
"""