config.add_route(name="game_info", pattern="/game/{id:\d+}", view=game_info,
renderer='game_info.mako')
+ 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')
--- /dev/null
+<%inherit file="base.mako"/>
+
+<%block name="title">
+Server Game Index for ${server.name} - ${parent.title()}
+</%block>
+
+% if not games:
+<h2>Sorry, no games yet. Get playing on the server!</h2>
+
+% else:
+<h2>Games on ${server.name}</h2>
+<ul>
+% for (game, theserver, 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("game_index_paged", page=games.previous_page)}" name="Previous Page">Previous</a>
+% endif
+% if games.next_page:
+<a href="${request.route_url("game_index_paged", page=games.next_page)}" name="Next Page">Next</a>
+% endif
<li><a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> (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>)</li>
% endfor
</ul>
-More games played on ${server.name}...
+<a href="${request.route_url("server_game_index", server_id=server.server_id, page=1)}" name="Game index page for server #${server.name}">More games played on ${server.name}...</a>
% endif
% endif
'recent_games':recent_games}
+def server_game_index(request):
+ server_id = request.matchdict['server_id']
+ current_page = request.matchdict['page']
+
+ try:
+ server = DBSession.query(Server).filter_by(server_id=server_id).one()
+
+ games_q = DBSession.query(Game, Server, Map).\
+ filter(Game.server_id == server_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("Server is:")
+ log.debug(server)
+ log.debug("Games is:")
+ log.debug(games)
+ except Exception as e:
+ server = None
+ games = None
+ raise e
+
+ return {'games':games,
+ 'server':server}
+
+
##########################################################################
# This is the map views area - only views pertaining to Xonotic
# maps and their related information goes here