Use gametype description for icon tooltips (e.g. ca -> Clan Arena)
authorJan Behrens <zykure@web.de>
Mon, 4 Feb 2013 21:37:31 +0000 (22:37 +0100)
committerJan Behrens <zykure@web.de>
Mon, 4 Feb 2013 21:37:31 +0000 (22:37 +0100)
xonstat/static/css/style.css
xonstat/templates/game_index.mako
xonstat/templates/game_info.mako
xonstat/templates/main_index.mako
xonstat/templates/map_info.mako
xonstat/templates/player_info.mako
xonstat/templates/server_info.mako
xonstat/views/game.py
xonstat/views/helpers.py

index a7e2cb8..7a7c6b1 100755 (executable)
@@ -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;
 }
 
index a8f1723..0e8a037 100644 (file)
@@ -18,9 +18,11 @@ Game Index
 <div class="row">
   <div class="span12">
     <h2>Recent Games</h2>
-    % for (game, server, map) in games:
+    % for (game, server, map, gametype) in games:
     <div class="game">
-      <h4><img src="/static/images/icons/48x48/${game.game_type_cd}.png" width="30" height="30" /><a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> on <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a> <span class="permalink">(<a href="${request.route_url('game_info', id=game.game_id)}" name="Permalink for game #${game.game_id}">permalink</a>)</span></h4>
+      <img src="/static/images/icons/48x48/${game.game_type_cd}.png" width="30" height="30" alt="${game.game_type_cd}" title="${gametype.descr}"/>
+      <h4><a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> on <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a> <span class="permalink">(<a href="${request.route_url('game_info', id=game.game_id)}" name="Permalink for game #${game.game_id}">permalink</a>)</span></h4>
+      <span class="clear"></span>
       ${scoreboard(game.game_type_cd, pgstats[game.game_id])}
     </div>
     % endfor
index 841e3d9..7e7e80e 100644 (file)
@@ -34,10 +34,10 @@ Game Information
 <div class="row">
   <div class="span10 game-detail">
     <h2>Game Detail</h2>
-    <img width="48" height="48" src="/static/images/icons/48x48/${game.game_type_cd}.png" alt="${game.game_type_cd}" title="${game.game_type_cd}"/>
+    <img width="48" height="48" src="/static/images/icons/48x48/${game.game_type_cd}.png" alt="${game.game_type_cd}"/>
     <p>
       Played: <span class="abstime" data-epoch="${game.epoch()}" title="${game.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${game.fuzzy_date()}</span><br />
-      Game Type: ${game.game_type_cd}<br />
+      Game Type: ${game.game_type_cd} (${gametype.descr})<br />
       Server: <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a><br />
       Map: <a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a><br />
       % if game.duration is not None:
index 74a9d5f..f1dd2b1 100644 (file)
@@ -176,7 +176,7 @@ Leaderboard
         <tr>
           <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
           <!-- <td class="gt_icon"><img title="${rg.game_type_cd}" src="/static/images/icons/24x24/${rg.game_type_cd}.png" alt="${rg.game_type_cd}" /></td> -->
-          <td><span class="sprite sprite-${rg.game_type_cd}" title="${rg.game_type_cd}"></span></td>
+          <td><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
           <td><a href="${request.route_url('server_info', id=rg.server_id)}" title="Go to the detail page for this server">${rg.server_name}</a></td>
           <td><a href="${request.route_url('map_info', id=rg.map_id)}" title="Go to the map detail page for this map">${rg.map_name}</a></td>
           <td><span class="abstime" data-epoch="${rg.epoch}" title="${rg.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${rg.fuzzy_date}</span></td>
index abbd4b0..ad2348a 100644 (file)
@@ -168,7 +168,7 @@ ${parent.title()}
         % for rg in recent_games:
         <tr>
           <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">View</a></td>
-          <td><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}"></span></td>
+          <td><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
           <td><a href="${request.route_url('server_info', id=rg.server_id)}" title="Go to the detail page for this server">${rg.server_name}</a></td>
           <td><span class="abstime" data-epoch="${rg.epoch}" title="${rg.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${rg.fuzzy_date}</span></td>
           <td>
index f08e7c3..4c7e740 100644 (file)
@@ -442,7 +442,7 @@ Player Information
       % for rg in recent_games:
         <tr>
            <td class="tdcenter"><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
-           <td class="tdcenter"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}"></span></td>
+           <td class="tdcenter"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
            <td>${rg.server_name}</td>
            <td>${rg.map_name}</td>
            <td>
index fef79a4..ef57cf4 100644 (file)
@@ -141,7 +141,7 @@ Server Information
         % for rg in recent_games:
         <tr>
           <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">View</a></td>
-          <td><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}"></span></td>
+          <td><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
           <td><a href="${request.route_url('map_info', id=rg.map_id)}" title="Go to the map detail page for this map">${rg.map_name}</a></td>
           <td><span class="abstime" data-epoch="${rg.epoch}" title="${rg.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${rg.fuzzy_date}</span></td>
           <td>
index 4c4800d..822604f 100644 (file)
@@ -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,
index 3e09e08..cbaed24 100644 (file)
@@ -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