config.add_view(game_info, route_name="game_info",
renderer="game_info.mako")
+ config.add_route("rank_index", "/ranks/{game_type_cd:ctf|dm|tdm|duel}")
+ config.add_view(rank_index, route_name="rank_index",
+ renderer="rank_index.mako")
+
+ config.add_route("rank_index_paged", "/ranks/{game_type_cd:ctf|dm|tdm|duel}/page/{page:\d+}")
+ config.add_view(rank_index, route_name="rank_index_paged",
+ renderer="rank_index.mako")
+
# SERVER ROUTES
config.add_route("server_index_paged", "/servers/page/{page:\d+}")
config.add_view(server_index, route_name="server_index_paged",
--- /dev/null
+<%inherit file="base.mako"/>\r
+<%namespace file="navlinks.mako" import="navlinks" />\r
+\r
+<%block name="title">\r
+Rank Index - ${parent.title()}\r
+</%block>\r
+\r
+% if not ranks:\r
+<h2>Sorry, no ranks yet. Get some buddies together and start playing!</h2>\r
+\r
+% else:\r
+<h2>\r
+% if game_type_cd == 'dm':\r
+Deathmatch \r
+% elif game_type_cd == 'duel':\r
+Duel \r
+% elif game_type_cd == 'tdm':\r
+Team Deathmatch \r
+% elif game_type_cd == 'ctf':\r
+Capture The Flag \r
+% endif\r
+\r
+Rank Index</h2>\r
+<table id="rank-index-table" border="1">\r
+ <tr>\r
+ <th>Rank</th>\r
+ <th>Nick</th>\r
+ <th>Elo</th>\r
+ </tr>\r
+<% i = 1 %>\r
+% for (rank, player) in ranks:\r
+ <tr>\r
+ <td>${i}</td>\r
+ <td><a href="${request.route_url("player_info", id=rank.player_id)}" title="Go to this player's info page">${player.nick_html_colors()|n}</a></th>\r
+ <td>${round(rank.elo, 3)}</th>\r
+ </tr>\r
+<% i += 1 %>\r
+% endfor\r
+</table>\r
+\r
+<!-- navigation links -->\r
+${navlinks("rank_index_paged", ranks.page, ranks.last_page)}\r
+% endif\r
from xonstat.views.submission import stats_submit\r
from xonstat.views.player import player_index, player_info, player_game_index\r
-from xonstat.views.game import game_index, game_info\r
+from xonstat.views.game import game_index, game_info, rank_index\r
from xonstat.views.map import map_info, map_index\r
from xonstat.views.server import server_info, server_game_index, server_index\r
from xonstat.views.search import *\r
'pgstats':pgstats,\r
'pwstats':pwstats,\r
}\r
+\r
+\r
+def rank_index(request):\r
+ """\r
+ Provide a list of gametype ranks, paginated.\r
+ """\r
+ if 'page' in request.matchdict:\r
+ current_page = request.matchdict['page']\r
+ else:\r
+ current_page = 1\r
+\r
+ game_type_cd = request.matchdict['game_type_cd']\r
+\r
+ ranks_q = DBSession.query(PlayerElo, Player).\\r
+ filter(PlayerElo.game_type_cd==game_type_cd).\\r
+ filter(PlayerElo.player_id==Player.player_id).\\r
+ order_by(PlayerElo.elo.desc())\r
+\r
+ ranks = Page(ranks_q, current_page, url=page_url)\r
+\r
+ if len(ranks) == 0:\r
+ ranks = None\r
+\r
+ return {\r
+ 'ranks':ranks,\r
+ 'game_type_cd':game_type_cd,\r
+ }\r