From c93d4157bcfba775e14d860dd62b5f6cabb442f8 Mon Sep 17 00:00:00 2001 From: Michael Thies Date: Sun, 19 Jul 2020 18:38:17 +0200 Subject: [PATCH] web: Add game start time and explicit UTC timezone to result pages --- qaqa_bot/templates/game_result.mako.html | 3 +-- qaqa_bot/templates/sheet_result.mako.html | 4 +--- qaqa_bot/web.py | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qaqa_bot/templates/game_result.mako.html b/qaqa_bot/templates/game_result.mako.html index 89aa81a..7401072 100644 --- a/qaqa_bot/templates/game_result.mako.html +++ b/qaqa_bot/templates/game_result.mako.html @@ -6,9 +6,8 @@ .format(game_name=game.name,\ date=format_date(game.finished, locale=lang))} | QAQA Game Bot -## TODO add date

${gettext("Game in {game_name}").format(game_name=game.name)}

-
${format_datetime(game.finished, locale=lang)}
+
${format_datetime(game.started, locale=lang)} – ${format_datetime(game.finished, locale=lang)} (UTC)
% for sheet in game.sheets: ${util.print_sheet(sheet=sheet)} diff --git a/qaqa_bot/templates/sheet_result.mako.html b/qaqa_bot/templates/sheet_result.mako.html index e874502..3ecd55f 100644 --- a/qaqa_bot/templates/sheet_result.mako.html +++ b/qaqa_bot/templates/sheet_result.mako.html @@ -7,10 +7,8 @@ date=format_date(sheet.game.finished, locale=lang))} | QAQA Game Bot - -## TODO add date

${gettext("Sheet from {game_name}").format(game_name=sheet.game.name)}

-
${format_datetime(sheet.game.finished, locale=lang)}
+
${format_datetime(sheet.game.started, locale=lang)} – ${format_datetime(sheet.game.finished, locale=lang)} (UTC)
${util.print_sheet(sheet=sheet)} diff --git a/qaqa_bot/web.py b/qaqa_bot/web.py index 4af77ed..74ec827 100644 --- a/qaqa_bot/web.py +++ b/qaqa_bot/web.py @@ -26,6 +26,8 @@ To simplify setup of the cherrypy engine (including the WebRoot Controller, HTTP server config, no autoreload and custom error page), the `setup_cherrypy_engine()` function is provided. """ +import datetime +import functools import gettext import os from typing import Dict, Any, Optional @@ -93,7 +95,7 @@ def __init__(self, config: Dict[str, Any], game_server: GameServer): 'static_url': lambda file_name: "{}/static/{}".format(config['web']['base_url'], file_name), # TODO add version to control caching 'encode_id': lambda realm, val: encode_secure_id(val, config['secret'], realm), 'format_date': babel.dates.format_date, - 'format_datetime': babel.dates.format_datetime, + 'format_datetime': functools.partial(babel.dates.format_datetime, tzinfo=datetime.timezone.utc), } def render_template(self, template_name: str, params: Dict[str, Any], locale: Optional[str] = None) -> str: