def import_game_data(csv_file): with open(csv_file) as f: reader = csv.DictReader(f) for row in reader: print row GameInfo().create_one(row['game_id'], unicode(row['score_to_money_rate'], 'utf-8'), [ { 'player_id': unicode(row['player1_id'], 'utf-8'), 'player_score': row['player1_score'], 'game_id': row['game_id'] }, { 'player_id': unicode(row['player2_id'], 'utf-8'), 'player_score': row['player2_score'], 'game_id': row['game_id'] }, { 'player_id': unicode(row['player3_id'], 'utf-8'), 'player_score': row['player3_score'], 'game_id': row['game_id'] }, { 'player_id': unicode(row['player4_id'], 'utf-8'), 'player_score': row['player4_score'], 'game_id': row['game_id'] } ])
def add_game_action(self): json_body = json.loads(self.request.body) GameInfo().create_one(self.game_type_pkid, self.user_pkid, json_body['game_id'], json_body['score_to_money_rate'], json_body['result']) self.output_json()
def edit_game_action(self): json_body = json.loads(self.request.body) GameInfo().update_one(self.game_type_pkid, self.user_pkid, json_body['game_pkid'], json_body['game_id'], json_body['score_to_money_rate'], json_body['game_finish_datetime'], json_body['result']) self.output_json()
def games_by_created_at_action(self): start_dt = self.get_argument_datetime('start_dt') end_dt = self.get_argument_datetime('end_dt') self.output_json(data=GameInfo().get_data_by_date( self.game_type_pkid, self.user_pkid, start_dt, end_dt))
def games_action(self): self.output_json( data=GameInfo().get_all(self.game_type_pkid, self.user_pkid))
def game_type_by_pkid_action(self): result = GameInfo().get_game_type_by_pkid(self.game_type_pkid) self.output_json(data=result)
def game_list_action(self): self.check_priv_by_game_type_pkid() game_type_info = GameInfo().get_game_type_by_pkid(self.game_type_pkid) self.output_game_template( 'game_list.html', most_player_count=game_type_info['most_player_count'])
def del_game_action(self): game_pkid = self.get_argument_int('game_pkid') GameInfo().delete_one(game_pkid) self.output_json()