Skip to content

Commit

Permalink
web: Add game start time and explicit UTC timezone to result pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mhthies committed Jul 19, 2020
1 parent 24e98b4 commit c93d415
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions qaqa_bot/templates/game_result.mako.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
.format(game_name=game.name,\
date=format_date(game.finished, locale=lang))} | QAQA Game Bot</%block>

## TODO add date
<h1>${gettext("Game in {game_name}").format(game_name=game.name)}</h1>
<div class="subtitle">${format_datetime(game.finished, locale=lang)}</div>
<div class="subtitle">${format_datetime(game.started, locale=lang)} – ${format_datetime(game.finished, locale=lang)} (UTC)</div>

% for sheet in game.sheets:
${util.print_sheet(sheet=sheet)}
Expand Down
4 changes: 1 addition & 3 deletions qaqa_bot/templates/sheet_result.mako.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
date=format_date(sheet.game.finished, locale=lang))}
| QAQA Game Bot</%block>


## TODO add date
<h1>${gettext("Sheet from {game_name}").format(game_name=sheet.game.name)}</h1>
<div class="subtitle">${format_datetime(sheet.game.finished, locale=lang)}</div>
<div class="subtitle">${format_datetime(sheet.game.started, locale=lang)} – ${format_datetime(sheet.game.finished, locale=lang)} (UTC)</div>

${util.print_sheet(sheet=sheet)}

Expand Down
4 changes: 3 additions & 1 deletion qaqa_bot/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c93d415

Please sign in to comment.