renderer="main_index.mako")
# PLAYER ROUTES
- config.add_route("player_game_index_default",
- "/player/{player_id:\d+}/games")
- config.add_view(player_game_index, route_name="player_game_index_default",
+ config.add_route("player_game_index_paged",
+ "/player/{player_id:\d+}/games/page/{page:\d+}")
+ config.add_view(player_game_index, route_name="player_game_index_paged",
renderer="player_game_index.mako")
config.add_route("player_game_index",
- "/player/{player_id:\d+}/games/page/{page:\d+}")
- config.add_view(player_game_index, renderer="player_game_index.mako")
+ "/player/{player_id:\d+}/games")
+ config.add_view(player_game_index, route_name="player_game_index",
+ renderer="player_game_index.mako")
config.add_route("player_index_paged", "/players/page/{page:\d+}")
config.add_view(player_index, route_name="player_index_paged",
<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+<%namespace file="scoreboard.mako" import="scoreboard" />
+<%namespace file="navlinks.mako" import="navlinks" />
+
+<%block name="navigation">
+${nav.nav('games')}
+</%block>
<%block name="title">
-Player Game Index for ${player.nick_html_colors()|n} - ${parent.title()}
+Game Index
</%block>
% if not games:
-<h2>Sorry, no games yet. Get playing, scrub!</h2>
+<h2>Sorry, no games yet. Get playing!</h2>
% else:
-<h2>Recent Games by ${player.nick_html_colors()|n}</h2>
-% for (playergamestat, game, server, map) in games:
- <li><a href="${request.route_url("game_info", id=game.game_id)}" name="Game info page for game #${game.game_id}">#${game.game_id}:</a> <a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a></li>
-% endfor
-<br />
-% endif
+<div class="row">
+ <div class="span12">
+ <h2>Recent Games</h2>
+ % for (game, server, map) 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>
+ ${scoreboard(game.game_type_cd, pgstats[game.game_id])}
+ </div>
+ % endfor
+ </div>
+</div>
-% if games.previous_page:
-<a href="${request.route_url("player_game_index", player_id=player.player_id, page=games.previous_page)}" name="Previous Page">Previous</a>
-% endif
-% if games.next_page:
-<a href="${request.route_url("player_game_index", player_id=player.player_id, page=games.next_page)}" name="Next Page">Next</a>
+<!-- navigation links -->
+${navlinks("player_game_index_paged", games.page, games.last_page, player_id=player_id)}
% endif
</tbody>
</table>
% if game_stats['total_games_played'] > 10:
- <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More games</a> played by ${player.nick_html_colors()|n}...
+ <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More games played by ${player.nick_html_colors()|n}...</a>
% endif
</div>
</div>
filter(sa.not_(Player.nick.like('Anonymous Player%'))).\\r
order_by(Player.player_id.desc())\r
\r
- players = Page(player_q, current_page, url=page_url)\r
+ players = Page(player_q, current_page, items_per_page=10, url=page_url)\r
\r
last_linked_page = current_page + 4\r
if last_linked_page > players.last_page:\r
current_page = 1\r
\r
try:\r
- player = DBSession.query(Player).filter_by(player_id=player_id).one()\r
-\r
- games_q = DBSession.query(PlayerGameStat, Game, Server, Map).\\r
- filter(PlayerGameStat.player_id == player_id).\\r
- filter(PlayerGameStat.game_id == Game.game_id).\\r
- filter(Game.server_id == Server.server_id).\\r
- filter(Game.map_id == Map.map_id).\\r
- order_by(Game.game_id.desc())\r
+ games_q = DBSession.query(Game, Server, Map).\\r
+ filter(PlayerGameStat.game_id == Game.game_id).\\r
+ filter(PlayerGameStat.player_id == player_id).\\r
+ filter(Game.server_id == Server.server_id).\\r
+ filter(Game.map_id == Map.map_id).\\r
+ order_by(Game.game_id.desc())\r
\r
games = Page(games_q, current_page, url=page_url)\r
\r
- \r
+ pgstats = {}\r
+ for (game, server, map) in games:\r
+ pgstats[game.game_id] = DBSession.query(PlayerGameStat).\\r
+ filter(PlayerGameStat.game_id == game.game_id).\\r
+ order_by(PlayerGameStat.rank).\\r
+ order_by(PlayerGameStat.score).all()\r
+\r
except Exception as e:\r
player = None\r
games = None\r
\r
- return {'player':player,\r
- 'games':games}\r
+ return {'player_id':player_id,\r
+ 'games':games,\r
+ 'pgstats':pgstats}\r