% else:\r
<h2>Recent Games</h2>\r
<ul>\r
-% for (game_id, server_id, server_name, map_id, map_name) in games:\r
- <li>game <a href="${request.route_url("game_info", id=game_id)}" name="Game info page for game #${game_id}">#${game_id}:</a> <a href="${request.route_url("map_info", id=map_id)}" name="Map info page for ${map_name}">${map_name}</a> on <a href="${request.route_url("server_info", id=server_id)}" name="Server info page for ${server_name}">${server_name}</a></li>\r
+% for (game, server, map) in games:\r
+ <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> on <a href="${request.route_url("server_info", id=server.server_id)}" name="Server info page for ${server.name}">${server.name}</a></li>\r
% endfor\r
</ul>\r
% endif\r
+\r
+% if games.last_page:\r
+<a href="${request.route_url("game_index_paged", page=games.previous_page)}" name="Previous Page">Previous</a>\r
+% endif\r
+% if games.next_page:\r
+<a href="${request.route_url("game_index_paged", page=games.next_page)}" name="Next Page">Next</a>\r
+% endif\r
from xonstat.models import *
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
+from sqlalchemy import desc
import logging
return current_route_url(request, page=page, _query=request.GET)
def game_index(request):
- if 'page_number' in request.matchdict:
- current_page = request.matchdict['page_number']
+ if 'page' in request.matchdict:
+ current_page = request.matchdict['page']
else:
current_page = 1
- games_q = DBSession.query("game_id", "server_id", "server_name",
- "map_id", "map_name").\
- from_statement("select g.game_id, s.server_id, "
- "s.name as server_name, m.map_id, m.name as map_name "
- "from games g, servers s, maps m "
- "where g.server_id = s.server_id "
- "and g.map_id = m.map_id "
- "order by g.start_dt desc")
+ games_q = DBSession.query(Game, Server, Map).\
+ 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)
+
return {'games':games}