Display datetimes with local timezone

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-31 22:46:40 +02:00
parent 10a42d3633
commit 4efce6e325
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,7 @@ from django.urls import reverse_lazy
from django.utils import timezone from django.utils import timezone
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.text import format_lazy from django.utils.text import format_lazy
from django.utils.timezone import localtime
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
import gspread import gspread
from gspread.utils import a1_range_to_grid_range, MergeType from gspread.utils import a1_range_to_grid_range, MergeType
@ -109,7 +110,7 @@ class Team(models.Model):
text = _("Registrations for the tournament of {tournament} are ending on the {date:%Y-%m-%d %H:%M}.") text = _("Registrations for the tournament of {tournament} are ending on the {date:%Y-%m-%d %H:%M}.")
content = format_lazy(text, content = format_lazy(text,
tournament=self.participation.tournament.name, tournament=self.participation.tournament.name,
date=self.participation.tournament.inscription_limit) date=localtime(self.participation.tournament.inscription_limit))
informations.append({ informations.append({
'title': _("Registrations closure"), 'title': _("Registrations closure"),
'type': "info", 'type': "info",
@ -715,7 +716,7 @@ class Participation(models.Model):
"We suggest to send at least <strong>{min_solutions}</strong> different solutions.</p>" "We suggest to send at least <strong>{min_solutions}</strong> different solutions.</p>"
"<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>") "<p>You can upload your solutions on <a href='{url}'>your participation page</a>.</p>")
url = reverse_lazy("participation:participation_detail", args=(self.pk,)) url = reverse_lazy("participation:participation_detail", args=(self.pk,))
content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solution_limit, content = format_lazy(text, tournament=self.tournament.name, date=localtime(self.tournament.solution_limit),
nb_solutions=self.solutions.count(), min_solutions=len(settings.PROBLEMS) - 3, nb_solutions=self.solutions.count(), min_solutions=len(settings.PROBLEMS) - 3,
url=url) url=url)
informations.append({ informations.append({
@ -728,7 +729,8 @@ class Participation(models.Model):
text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the " text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the "
"{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>") "{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>")
url = reverse_lazy("draw:index") url = reverse_lazy("draw:index")
content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solutions_draw, url=url) content = format_lazy(text, tournament=self.tournament.name,
date=localtime(self.tournament.solutions_draw), url=url)
informations.append({ informations.append({
'title': _("Draw of solutions"), 'title': _("Draw of solutions"),
'type': "info", 'type': "info",

View File

@ -14,6 +14,7 @@ from django.utils.crypto import get_random_string
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode from django.utils.http import urlsafe_base64_encode
from django.utils.text import format_lazy from django.utils.text import format_lazy
from django.utils.timezone import localtime
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from phonenumber_field.modelfields import PhoneNumberField from phonenumber_field.modelfields import PhoneNumberField
from polymorphic.models import PolymorphicModel from polymorphic.models import PolymorphicModel
@ -471,7 +472,7 @@ class VolunteerRegistration(Registration):
text = _("Registrations for tournament {tournament} are closing on {date:%Y-%m-%d %H:%M}. " text = _("Registrations for tournament {tournament} are closing on {date:%Y-%m-%d %H:%M}. "
"There are for now {validated_teams} validated teams (+ {pending_teams} pending) " "There are for now {validated_teams} validated teams (+ {pending_teams} pending) "
"on {max_teams} expected.") "on {max_teams} expected.")
content = format_lazy(text, tournament=tournament.name, date=tournament.inscription_limit, content = format_lazy(text, tournament=tournament.name, date=localtime(tournament.inscription_limit),
validated_teams=tournament.participations.filter(valid=True).count(), validated_teams=tournament.participations.filter(valid=True).count(),
pending_teams=tournament.participations.filter(valid=False).count(), pending_teams=tournament.participations.filter(valid=False).count(),
max_teams=tournament.max_teams) max_teams=tournament.max_teams)
@ -517,7 +518,8 @@ class VolunteerRegistration(Registration):
text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the " text = _("<p>The draw of the solutions for the tournament {tournament} is planned on the "
"{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>") "{date:%Y-%m-%d %H:%M}. You can join it on <a href='{url}'>this link</a>.</p>")
url = reverse_lazy("draw:index") url = reverse_lazy("draw:index")
content = format_lazy(text, tournament=self.tournament.name, date=self.tournament.solutions_draw, content = format_lazy(text, tournament=self.tournament.name,
date=localtime(self.tournament.solutions_draw),
url=url) url=url)
informations.append({ informations.append({
'title': _("Draw of solutions"), 'title': _("Draw of solutions"),