Ejemplo n.º 1
0
 def POST(self, worker_id, game_number):
     # First make sure the user hasn't already customized
     
     game_id = model.get_game_id(worker_id, game_number)
     print "checking current game status"
     check = model.check_current_game_status(worker_id, game_id)
     if check:
         raise web.seeother('/error/5?worker_id=' + worker_id)
     
     
     post_data = web.input()
     selections = post_data.selections
     ## Put the selections into a dict
     
     temp = selections.split(',')
     data = {}
     i = 1
     while i < 6:
         try:
             data[i] = temp[i-1]
         except IndexError:
             data[i] = "NULL"
         i += 1
     
     condition = model.get_condition(worker_id)   
     
     game_data = model.get_game_data(game_id)
     #game_number = model.get_games_played(worker_id) + 1
     game_number = int(game_number)
     prediction_quality = model.get_prediction_quality(worker_id, game_id)
     model.update_prediction_start_custom(worker_id, data, prediction_quality)
     
     raise web.seeother("/view_prediction/" + worker_id + "/" + str(game_number))
Ejemplo n.º 2
0
 def GET(self, worker_id, game_number):
     #var_names_batting = {"ba": "Batting Average", "runs": "Runs", "H":"Hits", "2B":"2B", "3B":"3B", "HR":"Home Runs", "OBP":"On-Base Percentage", "SLG":"Slugging Percentage", "BB":"Walks", "SB":"Stolen Bases", "RBI":"Runs Batted In"}
     #var_names_team_pitching = {"ERAp": "Earned Run Average", "BBp":"Walks", "SOp":"Strikeouts", "HRp":"Home Runs"}
     #var_names_starter_pitching = {"Wsp":"Wins", "Lsp":"Losses", "ERAsp":"Earned Run Average", "Hsp": "Hits", "SOsp":"Strikeouts", "HRsp":"Home Runs", "IPsp":"Innings Pitched"}
     
     #worker_id = web.input(worker_id='').worker_id
     condition = model.get_condition(worker_id)
     if condition > 1:
         # If a condition isn't returned, redirect to an error page
         raise web.seeother('/error/3')
     
     # Returns an int with the id number of the next game, or None if 12 games have been played
     #game_number = model.get_games_played(worker_id) + 1
     game_number = int(game_number)
     game_id = model.get_game_id(worker_id, game_number)
     if not game_id:
         raise web.seeother('/survey/' + worker_id)
     game_data = model.get_game_data(game_id)
     
     # First, check to see if there is an existing prediction entry for this user with this game
     check1 = model.check_for_existing_prediction_record(worker_id, game_id)
     
     if check1 != 0:
         check2 = model.check_current_game_status(worker_id, game_id)
         
         if not check2:
             if condition == 1:
                 raise web.seeother('/customize_simulator/' + worker_id + "/" + str(game_number))
             else:
                 print "check2 caught"
                 return render_game.game_overview(worker_id, condition, game_data, var_names_batting, var_names_team_pitching, var_names_starter_pitching, game_number)
             
         else:
             raise web.seeother('/view_prediction/' + worker_id + "/" + str(game_number))
         
         
     
     
     
     ## If all games have been played, redirect to the survey
     #if not game_id:
     #    model.update_stage(worker_id)
     #    raise web.seeother('/survey/' + worker_id)
     #    
     ##Figure out if this game has already begun, and if so, redirect to the correct point in the game
     #status_check = model.get_current_game_status(worker_id, game_id)
     #if status_check == 2:
     #    raise web.seeother("/view_prediction/" + worker_id)
         
     ## create an entry in the predictions table for this game and this user
     #if status_check == 0:
     #    model.create_prediction_entry(worker_id, game_id)
     
     model.create_prediction_entry(worker_id, game_id)
     if condition == 1:
         raise web.seeother('/customize_simulator/' + worker_id + "/" + str(game_number))
     else:
         return render_game.game_overview(worker_id, condition, game_data, var_names_batting, var_names_team_pitching, var_names_starter_pitching, game_number)
Ejemplo n.º 3
0
 def GET(self, worker_id, game_number):
     model.update_prediction_custom_start(worker_id)
     #game_number = model.get_games_played(worker_id) + 1
     game_number = int(game_number)
     game_id = model.get_game_id(worker_id, game_number)
     game_data = model.get_game_data(game_id)
     
     #check that they haven't already customized
     check = model.check_current_game_status(worker_id, game_id)
     if check:
         raise web.seeother('/error/5?worker_id=' + worker_id)
     
     return render_game.customize(worker_id, game_data, var_names_batting, var_names_team_pitching, var_names_starter_pitching, game_number)
Ejemplo n.º 4
0
 def GET(self, worker_id, game_number):
     condition = model.get_condition(worker_id)
     
     if condition > 1:
         raise web.seeother('/error/3')
     
     #game_number = model.get_games_played(worker_id) + 1
     game_number = int(game_number)
     game_id = model.get_game_id(worker_id, game_number)
     game_data = model.get_game_data(game_id)
     prediction_quality = model.get_prediction_quality(worker_id, game_id)
     if condition == 0:
         model.update_prediction_start_fixed(worker_id, prediction_quality)
     return render_game.predictions(worker_id, condition, game_data, var_names_batting, var_names_team_pitching, var_names_starter_pitching, prediction_quality, game_number)