pattern="/player/{player_id:\d+}/games/page/{page:\d+}",
view=player_game_index, renderer='player_game_index.mako')
+ config.add_route(name="player_index_paged",
+ pattern="/players/page/{page:\d+}", view=player_index,
+ renderer='player_index.mako')
+
+ config.add_route(name="player_index", pattern="/players", view=player_index,
+ renderer='player_index.mako')
+
config.add_route(name="player_info", pattern="/player/{id:\d+}", view=player_info,
renderer='player_info.mako')
<h3>Player Statistics for Xonotic</h3>
</%block>
<ul id="nav">
+ <li><a href="/players" title="Player Index">players</a></li>
<li><a href="/games" title="Game Index">games</a></li>
<li><a href="" title="Map Index">maps</a></li>
<li><a href="" title="Server Index">servers</a></li>
--- /dev/null
+<%inherit file="base.mako"/>\r
+\r
+<%block name="title">\r
+Player Index - ${parent.title()}\r
+</%block>\r
+\r
+% if not players:\r
+<h2>Sorry, no players yet. Get playing!</h2>\r
+\r
+% else:\r
+<h2>Player Index</h2>\r
+<table border="1">\r
+ <tr>\r
+ <th>#</th>\r
+ <th>Nick</th>\r
+ <th>Joined</th>\r
+ </tr>\r
+% for player in players:\r
+ <tr>\r
+ <td>${player.player_id}</th>\r
+ <td>${player.nick_html_colors()}</th>\r
+ <td>${player.create_dt.strftime('%m/%d/%Y at %H:%M')}</th>\r
+ </tr>\r
+% endfor\r
+</table>\r
+% endif\r
+\r
+% if players.previous_page:\r
+<a href="${request.route_url("player_index_paged", page=players.previous_page)}" name="Previous Page">Previous</a>\r
+% endif\r
+% if players.next_page:\r
+<a href="${request.route_url("player_index_paged", page=players.next_page)}" name="Next Page">Next</a>\r
+% endif\r
"""\r
Provides a list of all the current players. \r
"""\r
- players = DBSession.query(Player)\r
+ if 'page' in request.matchdict:\r
+ current_page = request.matchdict['page']\r
+ else:\r
+ current_page = 1\r
+\r
+ try:\r
+ player_q = DBSession.query(Player).\\r
+ filter(Player.player_id > 2).\\r
+ order_by(Player.player_id)\r
+\r
+ players = Page(player_q, current_page, url=page_url)\r
+\r
+ \r
+ except Exception as e:\r
+ players = None\r
+\r
+ return {'players':players, }\r
\r
- return {'players':players}\r
\r
def player_info(request):\r
"""\r