1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-03 17:22:51 +02:00

Better date render

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

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