config.add_route(name="main_index", pattern="/", view=main_index,
renderer='index.jinja2')
+ # PLAYER ROUTES
+ config.add_route(name="player_game_index",
+ pattern="/player/{player_id:\d+}/games/page/{page:\d+}",
+ view=player_game_index, renderer='player_game_index.mako')
+
config.add_route(name="player_info", pattern="/player/{id:\d+}", view=player_info,
renderer='player_info.mako')
+ # GAME ROUTES
config.add_route(name="game_index", pattern="/games", view=game_index,
renderer='game_index.mako')
config.add_route(name="game_info", pattern="/game/{id:\d+}", view=game_info,
renderer='game_info.mako')
+ # SERVER ROUTES
config.add_route(name="server_game_index",
pattern="/server/{server_id:\d+}/games/page/{page:\d+}",
view=server_game_index, renderer='server_game_index.mako')
config.add_route(name="server_info", pattern="/server/{id:\d+}", view=server_info,
renderer='server_info.mako')
+ # MAP ROUTES
config.add_route(name="map_info", pattern="/map/{id:\d+}", view=map_info,
renderer='map_info.mako')
--- /dev/null
+<%inherit file="base.mako"/>
+
+<%block name="title">
+Player Game Index for ${player.nick} - ${parent.title()}
+</%block>
+
+% if not games:
+<h2>Sorry, no games yet. Get playing, scrub!</h2>
+
+% else:
+<h2>Recent Games by ${player.nick}</h2>
+<ul>
+% for (playergamestat, game, server, map) in games:
+ <li>game <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
+</ul>
+% endif
+
+% 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>
+% endif
'recent_games':recent_games}
+def player_game_index(request):
+ player_id = request.matchdict['player_id']
+ current_page = request.matchdict['page']
+
+ try:
+ player = DBSession.query(Player).filter_by(player_id=player_id).one()
+
+ games_q = DBSession.query(PlayerGameStat, Game, Server, Map).\
+ filter(PlayerGameStat.player_id == player_id).\
+ filter(PlayerGameStat.game_id == Game.game_id).\
+ filter(Game.server_id == Server.server_id).\
+ filter(Game.map_id == Map.map_id).\
+ order_by(Game.game_id.desc())
+
+ games = Page(games_q, current_page, url=page_url)
+
+ log.debug(games)
+ log.debug(player)
+
+ except Exception as e:
+ player = None
+ games = None
+ raise e
+
+ return {'player':player,
+ 'games':games}
+
+
##########################################################################
# This is the game views area - only views pertaining to Xonotic
# games and their related information goes here