config.add_view(player_game_index, route_name="player_game_index", renderer="player_game_index.mako")
config.add_view(player_game_index_json, route_name="player_game_index_json", renderer="jsonp")
+ config.add_route("player_game_index_filtered", "/player/{player_id:\d+}/games/{game_type_cd:\w+}")
+ config.add_route("player_game_index_filtered_json", "/player/{player_id:\d+}/games/{game_type_cd:\w+}.json")
+ config.add_view(player_game_index, route_name="player_game_index_filtered", renderer="player_game_index.mako")
+ config.add_view(player_game_index_json, route_name="player_game_index_filtered_json", renderer="jsonp")
+
config.add_route("player_info", "/player/{id:\d+}")
config.add_route("player_info_json", "/player/{id:\d+}.json")
config.add_view(player_info, route_name="player_info", renderer="player_info.mako")
% else:
<div class="row">
<div class="span12">
+ % if not game_type_cd:
<h3>Recent Games by ${player.nick_html_colors()|n}</h3>
+ % else:
+ <h3>Recent ${game_type_cd.upper()} Games by ${player.nick_html_colors()|n}</h3>
+ % endif
<p><a href="${player_url}">Back to player info page</a></p>
</div>
</div>
return "<RecentGame(id=%s, gametype=%s, server=%s, map=%s)>" % (self.game_id, self.game_type_cd, self.server_name, self.map_name)
-def recent_games_q(server_id=None, map_id=None, player_id=None, cutoff=None):
+def recent_games_q(server_id=None, map_id=None, player_id=None, game_type_cd=None, cutoff=None):
'''
Returns a SQLA query of recent game data. Parameters filter
the results returned if they are provided. If not, it is
recent_games_q = recent_games_q.\
filter(PlayerGameStat.rank==1)
+ if game_type_cd is not None:
+ recent_games_q = recent_games_q.\
+ filter(Game.game_type_cd==game_type_cd.lower())
+
if cutoff is not None:
right_now = datetime.utcnow()
recent_games_q = recent_games_q.\
def player_game_index_data(request):
player_id = request.matchdict['player_id']
+ try:
+ game_type_cd = request.matchdict['game_type_cd']
+ except:
+ game_type_cd = None
if request.params.has_key('page'):
current_page = request.params['page']
current_page = 1
try:
- player = DBSession.query(Player).filter_by(player_id=player_id).\
- filter(Player.active_ind == True).one()
+ player = DBSession.query(Player).\
+ filter_by(player_id=player_id).\
+ filter(Player.active_ind == True).\
+ one()
- rgs_q = recent_games_q(player_id=player.player_id)
+ rgs_q = recent_games_q(player_id=player.player_id, game_type_cd=game_type_cd)
games = Page(rgs_q, current_page, items_per_page=10, url=page_url)
return {
'player_id':player.player_id,
+ 'player_url':request.route_url('player_info', id=player_id),
'player':player,
'games':games,
+ 'game_type_cd':game_type_cd,
}
"""
return [{'status':'not implemented'}]
-
def player_accuracy_data(request):
player_id = request.matchdict['id']
allowed_weapons = ['nex', 'rifle', 'shotgun', 'uzi', 'minstanex']