示例#1
0
def redo_search():
    #should return results html here
    positions = ', '.join(_parse_check_box(POSITIONS))
    regions = ', '.join(_parse_check_box(REGIONS))
    languages = ', '.join(_parse_check_box(LANGUAGES))

    player_info = Player.build_player_info(request.form['username'], request.form['amount'], positions, regions, languages)
    current_player = Player(player_info)
    
    db = connect_db()
    current_player._update_user_to_db(db)
    # We are providing an mmr range of 200 as a search criteria
    matching_player_list = current_player.get_matching_players(200, db)
    my_results = []
    for matching_player_id in matching_player_list:
        my_results.append(get_steam_userinfo(matching_player_id))
    if my_results:
        results = ', '.join(my_results)
    else:
        results = 'Could not match MMR for your profile'

    session['redo_search'] = True
    #flash new player infos
    #concat player data into flash info
    flash(results)
    return render_template('index.html')
示例#2
0
def search():
    #should return results html here
    if not _parse_check_box(POSITIONS):
        flash('Please make sure to select positions')
        return render_template('index.html')
    else:
        positions = ', '.join(_parse_check_box(POSITIONS))
    if not _parse_check_box(REGIONS):
        flash('Please make sure to select regions')
        return render_template('index.html')
    else:
        regions = ', '.join(_parse_check_box(REGIONS))
    if not _parse_check_box(LANGUAGES):
        flash('Please make sure to select Languages')
        return render_template('index.html')
    else:
        languages = ', '.join(_parse_check_box(LANGUAGES))
    app.logger.info('Player input positions: {0}, regions: {1}, languages: {2} mmr: {3}'.format(positions, regions, languages, request.form['amount']))

    player_info = Player.build_player_info(request.form['username'], request.form['amount'], positions, regions, languages)

    app.logger.info('User with playername {0} requests to search'.format(player_info['username']))
    current_player = Player(player_info)
    
    db = connect_db()
    current_player._update_user_to_db(db)
    # We are providing an mmr range of 200 as a search criteria
    matching_player_list = current_player.get_matching_players(200, db)
    my_results = []
    for matching_player_id in matching_player_list:
        my_results.append(get_steam_userinfo(matching_player_id))
    if my_results:
        results = ', '.join(my_results)
    else:
        results = 'Could not match MMR for your profile'

    if session['logged_in']:
        session['redo_search'] = True

    #flash new player infos
    #concat player data into flash info
    flash(results)
    return render_template('index.html')