From 374d1c1a826ae60d1711c260af0fb12d4b58ed39 Mon Sep 17 00:00:00 2001 From: Jan Behrens Date: Mon, 4 Feb 2013 22:37:31 +0100 Subject: [PATCH] Use gametype description for icon tooltips (e.g. ca -> Clan Arena) --- xonstat/static/css/style.css | 12 ++++++++++-- xonstat/templates/game_index.mako | 6 ++++-- xonstat/templates/game_info.mako | 4 ++-- xonstat/templates/main_index.mako | 2 +- xonstat/templates/map_info.mako | 2 +- xonstat/templates/player_info.mako | 2 +- xonstat/templates/server_info.mako | 2 +- xonstat/views/game.py | 12 ++++++++---- xonstat/views/helpers.py | 14 +++++++++----- 9 files changed, 37 insertions(+), 19 deletions(-) diff --git a/xonstat/static/css/style.css b/xonstat/static/css/style.css index a7e2cb8..7a7c6b1 100755 --- a/xonstat/static/css/style.css +++ b/xonstat/static/css/style.css @@ -3525,13 +3525,21 @@ header h2 { display:none; } .table .tdcenter { text-align: center; } -/* Game Info */ +/* Game Info and Game Index*/ .game-detail img { float: left; margin-right: 10px; + margin-bottom: 5px; +} + +.game img { + float: left; + margin-right: 5px; + margin-bottom: 5px; } -.game-detail p { +.game-detail p, +.game h4 { float: left; } diff --git a/xonstat/templates/game_index.mako b/xonstat/templates/game_index.mako index a8f1723..0e8a037 100644 --- a/xonstat/templates/game_index.mako +++ b/xonstat/templates/game_index.mako @@ -18,9 +18,11 @@ Game Index

Recent Games

- % for (game, server, map) in games: + % for (game, server, map, gametype) in games:
-

${map.name} on ${server.name} (permalink)

+ ${game.game_type_cd} +

${map.name} on ${server.name} (permalink)

+ ${scoreboard(game.game_type_cd, pgstats[game.game_id])}
% endfor diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako index 841e3d9..7e7e80e 100644 --- a/xonstat/templates/game_info.mako +++ b/xonstat/templates/game_info.mako @@ -34,10 +34,10 @@ Game Information

Game Detail

- ${game.game_type_cd} + ${game.game_type_cd}

Played: ${game.fuzzy_date()}
- Game Type: ${game.game_type_cd}
+ Game Type: ${game.game_type_cd} (${gametype.descr})
Server: ${server.name}
Map: ${map.name}
% if game.duration is not None: diff --git a/xonstat/templates/main_index.mako b/xonstat/templates/main_index.mako index 74a9d5f..f1dd2b1 100644 --- a/xonstat/templates/main_index.mako +++ b/xonstat/templates/main_index.mako @@ -176,7 +176,7 @@ Leaderboard view - + ${rg.server_name} ${rg.map_name} ${rg.fuzzy_date} diff --git a/xonstat/templates/map_info.mako b/xonstat/templates/map_info.mako index abbd4b0..ad2348a 100644 --- a/xonstat/templates/map_info.mako +++ b/xonstat/templates/map_info.mako @@ -168,7 +168,7 @@ ${parent.title()} % for rg in recent_games: View - + ${rg.server_name} ${rg.fuzzy_date} diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako index f08e7c3..4c7e740 100644 --- a/xonstat/templates/player_info.mako +++ b/xonstat/templates/player_info.mako @@ -442,7 +442,7 @@ Player Information % for rg in recent_games: view - + ${rg.server_name} ${rg.map_name} diff --git a/xonstat/templates/server_info.mako b/xonstat/templates/server_info.mako index fef79a4..ef57cf4 100644 --- a/xonstat/templates/server_info.mako +++ b/xonstat/templates/server_info.mako @@ -141,7 +141,7 @@ Server Information % for rg in recent_games: View - + ${rg.map_name} ${rg.fuzzy_date} diff --git a/xonstat/views/game.py b/xonstat/views/game.py index 4c4800d..822604f 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -18,15 +18,16 @@ def _game_index_data(request): else: current_page = 1 - games_q = DBSession.query(Game, Server, Map).\ + games_q = DBSession.query(Game, Server, Map, GameType).\ filter(Game.server_id == Server.server_id).\ filter(Game.map_id == Map.map_id).\ + filter(Game.game_type_cd == GameType.game_type_cd).\ order_by(Game.game_id.desc()) games = Page(games_q, current_page, items_per_page=10, url=page_url) pgstats = {} - for (game, server, map) in games: + for (game, server, map, gametype) in games: pgstats[game.game_id] = DBSession.query(PlayerGameStat).\ filter(PlayerGameStat.game_id == game.game_id).\ order_by(PlayerGameStat.scoreboardpos).\ @@ -70,10 +71,11 @@ def _game_info_data(request): try: notfound = False - (game, server, map) = DBSession.query(Game, Server, Map).\ + (game, server, map, gametype) = DBSession.query(Game, Server, Map, GameType).\ filter(Game.game_id == game_id).\ filter(Game.server_id == Server.server_id).\ - filter(Game.map_id == Map.map_id).one() + filter(Game.map_id == Map.map_id).\ + filter(Game.game_type_cd == GameType.game_type_cd).one() pgstats = DBSession.query(PlayerGameStat).\ filter(PlayerGameStat.game_id == game_id).\ @@ -113,6 +115,7 @@ def _game_info_data(request): game = None server = None map = None + gametype = None pgstats = None pwstats = None captimes = None @@ -123,6 +126,7 @@ def _game_info_data(request): return {'game':game, 'server':server, 'map':map, + 'gametype':gametype, 'pgstats':pgstats, 'pwstats':pwstats, 'captimes':captimes, diff --git a/xonstat/views/helpers.py b/xonstat/views/helpers.py index 3e09e08..cbaed24 100644 --- a/xonstat/views/helpers.py +++ b/xonstat/views/helpers.py @@ -16,8 +16,9 @@ class RecentGame(object): The constructor takes a query row that has been fetched, and it requires the following columns to be present in the row: - game_id, game_type_cd, winner, start_dt, server_id, server_name, - map_id, map_name, player_id, nick, rank, team + game_id, game_type_cd, game_type_descr, winner, start_dt, + server_id, server_name, map_id, map_name, player_id, nick, + rank, team The following columns are optional: @@ -29,6 +30,7 @@ class RecentGame(object): def __init__(self, row): self.game_id = row.game_id self.game_type_cd = row.game_type_cd + self.game_type_descr = row.game_type_descr self.winner = row.winner self.start_dt = row.start_dt self.fuzzy_date = pretty_date(row.start_dt) @@ -52,6 +54,7 @@ class RecentGame(object): return { "game_id": self.game_id, "game_type_cd": self.game_type_cd, + "game_type_descr": self.game_type_descr, "winner": self.winner, "start_dt": self.start_dt, "fuzzy_dt": self.fuzzy_date, @@ -82,15 +85,16 @@ def recent_games_q(server_id=None, map_id=None, player_id=None, cutoff=None): look when querying. Only games that happened on or after the cutoff (which is a datetime object) will be returned. ''' - recent_games_q = DBSession.query(Game.game_id, Game.game_type_cd, - Game.winner, Game.start_dt, Server.server_id, - Server.name.label('server_name'), Map.map_id, + recent_games_q = DBSession.query(Game.game_id, GameType.game_type_cd, + Game.winner, Game.start_dt, GameType.descr.label('game_type_descr'), + Server.server_id, Server.name.label('server_name'), Map.map_id, Map.name.label('map_name'), PlayerGameStat.player_id, PlayerGameStat.nick, PlayerGameStat.rank, PlayerGameStat.team, PlayerGameStat.elo_delta).\ filter(Game.server_id==Server.server_id).\ filter(Game.map_id==Map.map_id).\ filter(Game.game_id==PlayerGameStat.game_id).\ + filter(Game.game_type_cd==GameType.game_type_cd).\ order_by(expr.desc(Game.game_id)) # the various filters provided get tacked on to the query -- 2.39.2