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))
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)