Adding links to access gametype-filtered lists
authorJan Behrens <zykure@web.de>
Wed, 17 Apr 2013 18:48:37 +0000 (20:48 +0200)
committerJan Behrens <zykure@web.de>
Wed, 17 Apr 2013 18:51:25 +0000 (20:51 +0200)
xonstat/templates/game_index.mako
xonstat/templates/player_game_index.mako
xonstat/templates/player_info.mako
xonstat/views/game.py
xonstat/views/player.py

index cf29f555cd9ffa7d488d485ea76a38e4efb8924c..da6205d56cb9c623bd51a3575599ddc188bf0358 100644 (file)
@@ -3,6 +3,11 @@
 <%namespace file="scoreboard.mako" import="scoreboard" />
 <%namespace file="navlinks.mako" import="navlinks" />
 
+<%block name="css">
+${parent.css()}
+<link href="/static/css/sprites.css" rel="stylesheet">
+</%block>
+
 <%block name="navigation">
 ${nav.nav('games')}
 </%block>
@@ -12,16 +17,41 @@ Game Index
 </%block>
 
 % if not games:
+  % if not game_type_cd:
 <h2>Sorry, no games yet. Get playing!</h2>
+  % else:
+<h2>Sorry, no ${game_type_cd.upper()} games yet. Get playing!</h2>
+  % endif
 
 % else:
 <div class="row">
-  <div class="span10 offset1">
+  <div class="span12">
     % if not game_type_cd:
     <h2>Recent Games</h2>
     % else:
     <h2>Recent ${game_type_cd.upper()} Games</h2>
     % endif
+  </div>
+</div>
+<div class="row">
+  <div class="span12 tabbable">
+    <ul class="nav nav-tabs">
+      % for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft','lms','as','dom','nb','cts','rc'):
+      ##% for gt in ('overall','duel','ctf','dm','tdm','ca','kh','ft','lms','as','dom','nb','cts','rc'):
+      <li>
+      % if gt == 'overall':
+      <a href="${request.route_url("game_index")}" alt="${gt}" title="" data-toggle="none">
+      % else:
+      <a href="${request.route_url("game_index_filtered", game_type_cd=gt)}" alt="${gt}" title="" data-toggle="none">
+      % endif
+        <span class="sprite sprite-${gt}"> </span><br />
+        ${gt} <br />
+      </a>
+      </li>
+      % endfor
+    </ul>
+  </div>
+  <div class="span12 offset1 tab-content">
     % for rg in games.items:
     <div class="game">
       <img src="/static/images/icons/48x48/${rg.game_type_cd}.png" width="30" height="30" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"/>
index c642568f254e1f35faf277b917850edfb380fcc4..c2fd6cee737020434f2b1d9b93f00b69636d8646 100644 (file)
@@ -2,6 +2,11 @@
 <%namespace name="nav" file="nav.mako" />
 <%namespace file="navlinks.mako" import="navlinks" />
 
+<%block name="css">
+${parent.css()}
+<link href="/static/css/sprites.css" rel="stylesheet">
+</%block>
+
 <%block name="navigation">
 ${nav.nav('games')}
 </%block>
@@ -11,7 +16,11 @@ Recent Games
 </%block>
 
 % if not games:
+  % if not game_type_cd:
 <h2>Sorry, no games yet. Get playing!</h2>
+  % else:
+<h2>Sorry, no ${game_type_cd.upper()} games yet. Get playing!</h2>
+  % endif
 <p><a href="${player_url}">Back to player info page</a></p>
 
 % else:
@@ -25,8 +34,25 @@ Recent Games
     <p><a href="${player_url}">Back to player info page</a></p>
   </div>
 </div>
+<br/>
 <div class="row">
-  <div class="span12">
+  <div class="span12 tabbable">
+    <ul class="nav nav-tabs">
+      % for game in games_played:
+      <li>
+      % if game.game_type_cd == 'overall':
+      <a href="${request.route_url("player_game_index", player_id=player.player_id)}" alt="${game.game_type_cd}" title="" data-toggle="none">
+      % else:
+      <a href="${request.route_url("player_game_index_filtered", player_id=player.player_id, game_type_cd=game.game_type_cd)}" alt="${game.game_type_cd}" title="" data-toggle="none">
+      % endif
+        <span class="sprite sprite-${game.game_type_cd}"> </span><br />
+        ${game.game_type_cd} <br />
+      </a>
+      </li>
+      % endfor
+    </ul>
+  </div>
+  <div class="span12 tab-content" style="margin-top:10px;">
     <table class="table table-hover table-condensed">
       <thead>
         <tr>
@@ -84,6 +110,7 @@ Recent Games
   </div>
 </div>
 
+
 <!-- navigation links -->
 ${navlinks("player_game_index", games.page, games.last_page, player_id=player_id)}
 % endif
index 24be3d3a35b52049e91750ad2d092ac89515825e..576c526da449d4fd1e6510ee4541d1c2895162e0 100644 (file)
@@ -266,7 +266,7 @@ Player Information
     <ul id="gbtab" class="nav nav-tabs">
       % for g in games_played:
       <li>
-      <a href="#tab-${g.game_type_cd}" data-toggle="tab">
+      <a href="#tab-${g.game_type_cd}" data-toggle="tab" alt="${g.game_type_cd}" title="">
         <span class="sprite sprite-${g.game_type_cd}"> </span><br />
         ${g.game_type_cd} <br />
         <small>(${g.games})</small>
index 3d3d44b0fcc8a1743e81bae39662cf001d8f8752..1ed1741f52eb4cbec54bf1ccbceed7f058e9cf85 100644 (file)
@@ -22,24 +22,31 @@ def _game_index_data(request):
         current_page = request.params['page']
     else:
         current_page = 1
-            
-    rgs_q = recent_games_q(game_type_cd=game_type_cd)
+    
+    try:
+        rgs_q = recent_games_q(game_type_cd=game_type_cd)
 
-    games = Page(rgs_q, current_page, items_per_page=10, url=page_url)
+        games = Page(rgs_q, current_page, items_per_page=10, url=page_url)
 
-    # replace the items in the canned pagination class with more rich ones
-    games.items = [RecentGame(row) for row in games.items]
-        
-    pgstats = {}
-    for game in games.items:
-        pgstats[game.game_id] = DBSession.query(PlayerGameStat).\
-                filter(PlayerGameStat.game_id == game.game_id).\
-                order_by(PlayerGameStat.scoreboardpos).\
-                order_by(PlayerGameStat.score).all()
+        # replace the items in the canned pagination class with more rich ones
+        games.items = [RecentGame(row) for row in games.items]
+            
+        pgstats = {}
+        for game in games.items:
+            pgstats[game.game_id] = DBSession.query(PlayerGameStat).\
+                    filter(PlayerGameStat.game_id == game.game_id).\
+                    order_by(PlayerGameStat.scoreboardpos).\
+                    order_by(PlayerGameStat.score).all()
+                    
+    except Exception as e:
+        games = None
+        pgstats = None
+        game_type_cd = None
 
     return {'games':games,
             'pgstats':pgstats,
-            'game_type_cd':game_type_cd}
+            'game_type_cd':game_type_cd,
+            }
 
 
 def game_index(request):
index 5f0fdef4ccd7543e51361584fee2be5373bf0170..952946055ba049c78362949cc16c79ae84158891 100644 (file)
@@ -618,10 +618,14 @@ def player_game_index_data(request):
 
         # replace the items in the canned pagination class with more rich ones
         games.items = [RecentGame(row) for row in games.items]
+        
+        games_played = get_games_played(player_id)
 
     except Exception as e:
         player = None
         games = None
+        game_type_cd = None
+        games_played = None
 
     return {
             'player_id':player.player_id,
@@ -629,6 +633,7 @@ def player_game_index_data(request):
             'player':player,
             'games':games,
             'game_type_cd':game_type_cd,
+            'games_played':games_played,
            }