Skip to content

Commit

Permalink
Merge branch 'master' of github.com:antzucaro/XonStat
Browse files Browse the repository at this point in the history
  • Loading branch information
antzucaro committed Nov 3, 2011
2 parents d45c99d + 6be2741 commit 02b767c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
5 changes: 4 additions & 1 deletion xonstat/views/player.py
Expand Up @@ -38,7 +38,10 @@ def player_info(request):
"""
Provides detailed information on a specific player
"""
player_id = request.matchdict['id']
player_id = int(request.matchdict['id'])
if player_id <= 2:
player_id = -1;

try:
player = DBSession.query(Player).filter_by(player_id=player_id).one()

Expand Down
30 changes: 18 additions & 12 deletions xonstat/views/submission.py
@@ -1,5 +1,6 @@
import datetime
import logging
import pyramid.httpexceptions
import re
import time
from pyramid.config import get_current_registry
Expand All @@ -22,12 +23,16 @@ def is_supported_gametype(gametype):


def verify_request(request):
(idfp, status) = d0_blind_id_verify(
sig=request.headers['X-D0-Blind-Id-Detached-Signature'],
querystring='',
postdata=request.body)
try:
(idfp, status) = d0_blind_id_verify(
sig=request.headers['X-D0-Blind-Id-Detached-Signature'],
querystring='',
postdata=request.body)

log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))
log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))
except:
idfp = None
status = None

return (idfp, status)

Expand Down Expand Up @@ -319,7 +324,7 @@ def create_player_game_stat(session=None, player=None,

# if the nick we end up with is different from the one in the
# player record, change the nick to reflect the new value
if pgstat.nick != player.nick and player.player_id > 1:
if pgstat.nick != player.nick and player.player_id > 2:
register_new_nick(session, player, pgstat.nick)

# if the player is ranked #1 and it is a team game, set the game's winner
Expand Down Expand Up @@ -464,21 +469,22 @@ def stats_submit(request):

(idfp, status) = verify_request(request)
if not idfp:
raise Exception("Request is not verified.")
raise pyramid.httpexceptions.HTTPUnauthorized

(game_meta, players) = parse_body(request)

if not has_required_metadata(game_meta):
log.debug("Required game meta fields (T, G, M, or S) missing. "\
log.debug("Required game meta fields missing. "\
"Can't continue.")
raise Exception("Required game meta fields (T, G, M, or S) missing.")
raise pyramid.exceptions.HTTPUnprocessableEntity

if not is_supported_gametype(game_meta['G']):
raise Exception("Gametype not supported.")
raise pyramid.httpexceptions.HTTPOk

if not has_minimum_real_players(players):
raise Exception("The number of real players is below the minimum. "\
"Stats will be ignored.")
log.debug("The number of real players is below the minimum. " +
"Stats will be ignored.")
raise pyramid.httpexceptions.HTTPOk

server = get_or_create_server(session=session, hashkey=idfp,
name=game_meta['S'])
Expand Down

0 comments on commit 02b767c

Please sign in to comment.