From ba53461e118749a8757cacd5172885a2ee7a93c5 Mon Sep 17 00:00:00 2001 From: Jan Behrens Date: Sun, 18 Aug 2013 16:20:26 +0200 Subject: [PATCH] Updating player hashkey view --- xonstat/__init__.py | 3 ++- xonstat/templates/player_hashkey_info_text.mako | 1 + xonstat/views/player.py | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xonstat/__init__.py b/xonstat/__init__.py index 49493d8..0433461 100644 --- a/xonstat/__init__.py +++ b/xonstat/__init__.py @@ -45,7 +45,8 @@ def main(global_config, **settings): config.add_route("player_game_index_json", "/player/{player_id:\d+}/games.json") config.add_view(player_game_index_json, route_name="player_game_index_json", renderer="jsonp") - config.add_route("player_hashkey_info_text", "/player/me") + #config.add_route("player_hashkey_info_text", "/player/me") + config.add_route("player_hashkey_info_text", "/player/{hashkey}") config.add_view(player_hashkey_info_text, route_name="player_hashkey_info_text", renderer="player_hashkey_info_text.mako") config.add_route("player_info", "/player/{id:\d+}") diff --git a/xonstat/templates/player_hashkey_info_text.mako b/xonstat/templates/player_hashkey_info_text.mako index cea9643..7b5f2ba 100644 --- a/xonstat/templates/player_hashkey_info_text.mako +++ b/xonstat/templates/player_hashkey_info_text.mako @@ -6,6 +6,7 @@ P ${hashkey} n ${player.nick} i ${player.player_id} e joined ${player_joined} +e joined_dt ${player_joined_dt} % if player.active_ind == True: e active-ind 1 % else: diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 824b980..87967b9 100644 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -791,13 +791,15 @@ def player_hashkey_info_data(request): (idfp, status) = verify_request(request) print "player_hashkey_info_data [idfp={0} status={1}]".format(idfp, status) + hashkey = request.matchdict['hashkey'] + # if config is to *not* verify requests and we get nothing back, this # query will return nothing and we'll 404. try: player = DBSession.query(Player).\ filter(Player.player_id == Hashkey.player_id).\ filter(Player.active_ind == True).\ - filter(Hashkey.hashkey == idfp).one() + filter(Hashkey.hashkey == hashkey).one() games_played = get_games_played(player.player_id) overall_stats = get_overall_stats(player.player_id) @@ -879,6 +881,7 @@ def player_hashkey_info_text(request): # one-offs for things needing conversion for text/plain player_joined = timegm(player.create_dt.timetuple()) + player_joined_dt = player.create_dt.strftime('%Y-%m-%d %H:%M:%SZ') alivetime = int(datetime_seconds(overall_stats['overall'].total_playing_time)) # this is a plain text response, if we don't do this here then @@ -891,6 +894,7 @@ def player_hashkey_info_text(request): 'player': player, 'hashkey': player_info['hashkey'], 'player_joined': player_joined, + 'player_joined_dt': player_joined_dt, 'games_played': games_played, 'overall_stats': overall_stats, 'alivetime': alivetime, -- 2.39.2