config.add_view(game_index, route_name="game_index", renderer="game_index.mako")
config.add_view(game_index_json, route_name="game_index_json", renderer="jsonp")
+ config.add_route("game_index_filtered", "/games/{game_type_cd:\w+}")
+ config.add_route("game_index_filtered_json", "/games/{game_type_cd:\w+}.json")
+ config.add_view(game_index, route_name="game_index_filtered", renderer="game_index.mako")
+ config.add_view(game_index_json, route_name="game_index_filtered_json", renderer="jsonp")
+
config.add_route("game_info", "/game/{id:\d+}")
config.add_route("game_info_json", "/game/{id:\d+}.json")
config.add_view(game_info, route_name="game_info", renderer="game_info.mako")
% else:
<div class="row">
<div class="span10 offset1">
+ % if not game_type_cd:
<h2>Recent Games</h2>
- % for (game, server, map, gametype) in games:
+ % else:
+ <h2>Recent ${game_type_cd.upper()} Games</h2>
+ % endif
+ % for rg in games.items:
<div class="game">
- <img src="/static/images/icons/48x48/${game.game_type_cd}.png" width="30" height="30" alt="${game.game_type_cd}" title="${gametype.descr}"/>
- <h4><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>
+ <img src="/static/images/icons/48x48/${rg.game_type_cd}.png" width="30" height="30" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"/>
+ <h4><a href="${request.route_url("map_info", id=rg.map_id)}" name="Map info page for ${rg.map_name}">${rg.map_name}</a> on <a href="${request.route_url("server_info", id=rg.server_id)}" name="Server info page for ${rg.server_name}">${rg.server_name}</a> <span class="permalink">(<a href="${request.route_url('game_info', id=rg.game_id)}" name="Permalink for game #${rg.game_id}">permalink</a>)</span></h4>
<span class="clear"></span>
- ${scoreboard(game.game_type_cd, pgstats[game.game_id])}
+ ${scoreboard(rg.game_type_cd, pgstats[rg.game_id])}
</div>
% endfor
</div>
<tr>
<td class="tdcenter"><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
<td class="tdcenter"><img title="${rg.game_type_cd}" src="/static/images/icons/24x24/${rg.game_type_cd}.png" alt="${rg.game_type_cd}" /></td>
- <td>${rg.server_name}</td>
- <td>${rg.map_name}</td>
+ <td><a href="${request.route_url("server_info", id=rg.server_id)}" name="Server info page for ${rg.server_name}">${rg.server_name}</a></td>
+ <td><a href="${request.route_url("map_info", id=rg.map_id)}" name="Map info page for ${rg.map_name}">${rg.map_name}</a></td>
<td>
% if rg.team != None:
% if rg.team == rg.winner:
def _game_index_data(request):
+ if request.matchdict.has_key('game_type_cd'):
+ game_type_cd = request.matchdict['game_type_cd']
+ else:
+ game_type_cd = None
+
if request.params.has_key('page'):
current_page = request.params['page']
else:
current_page = 1
+
+ rgs_q = recent_games_q(game_type_cd=game_type_cd)
- games_q = DBSession.query(Game, Server, Map, GameType).\
- filter(Game.server_id == Server.server_id).\
- filter(Game.map_id == Map.map_id).\
- filter(Game.game_type_cd == GameType.game_type_cd).\
- order_by(Game.game_id.desc())
-
- games = Page(games_q, current_page, items_per_page=10, url=page_url)
+ games = Page(rgs_q, current_page, items_per_page=10, url=page_url)
+ # replace the items in the canned pagination class with more rich ones
+ games.items = [RecentGame(row) for row in games.items]
+
pgstats = {}
- for (game, server, map, gametype) in games:
+ for game in games.items:
pgstats[game.game_id] = DBSession.query(PlayerGameStat).\
filter(PlayerGameStat.game_id == game.game_id).\
order_by(PlayerGameStat.scoreboardpos).\
order_by(PlayerGameStat.score).all()
return {'games':games,
- 'pgstats':pgstats}
+ 'pgstats':pgstats,
+ 'game_type_cd':game_type_cd}
def game_index(request):
def player_game_index_data(request):
player_id = request.matchdict['player_id']
- try:
+ if request.matchdict.has_key('game_type_cd'):
game_type_cd = request.matchdict['game_type_cd']
- except:
+ else:
game_type_cd = None
if request.params.has_key('page'):
"""
return [{'status':'not implemented'}]
+
def player_accuracy_data(request):
player_id = request.matchdict['id']
allowed_weapons = ['nex', 'rifle', 'shotgun', 'uzi', 'minstanex']