From: Ant Zucaro Date: Wed, 18 May 2011 17:47:08 +0000 (-0400) Subject: Redo SQLA query for game_index (it works!). Change template to utilize paging parameters. X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;ds=sidebyside;h=a69841976dc225317f831243c287114a1c499a75;p=xonotic%2Fxonstat.git Redo SQLA query for game_index (it works!). Change template to utilize paging parameters. --- diff --git a/xonstat/templates/game_index.mako b/xonstat/templates/game_index.mako index 56cb2a5..633ae74 100755 --- a/xonstat/templates/game_index.mako +++ b/xonstat/templates/game_index.mako @@ -10,8 +10,15 @@ Game Index - ${parent.title()} % else:

Recent Games

% endif + +% if games.last_page: +Previous +% endif +% if games.next_page: +Next +% endif diff --git a/xonstat/views.py b/xonstat/views.py index 3f9c58a..3086162 100755 --- a/xonstat/views.py +++ b/xonstat/views.py @@ -7,6 +7,7 @@ from webhelpers.paginate import Page, PageURL from xonstat.models import * from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound +from sqlalchemy import desc import logging @@ -63,22 +64,20 @@ def page_url(page): 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}