Ejemplo n.º 1
0
def Get(filterExpression = None):
    connection, cursor = basehandler.DbConnect()

    myQuery = "SELECT * FROM PLAYERS_DBT"

    if filterExpression is None:
        cursor = basehandler.DbExecute(myQuery, connection, cursor)
    else:
        myQuery += filterExpression.GetWhere()
        cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters())

    playerList = []

    for player in cursor.fetchall():
        tempPlayer = Player()

        tempPlayer.playerId = player[0]
        tempPlayer.firstName = player[1]
        tempPlayer.lastName = player[2]
        tempPlayer.birthday = player[3]
        tempPlayer.country = player[4]
        tempPlayer.height = player[5]
        
        playerList.append(tempPlayer)

    basehandler.DbClose(connection, cursor)

    return playerList
Ejemplo n.º 2
0
def player_add():
    if UserSession.currentUser is None:
        return redirect('/')
    
    if request.method == 'POST':
        
        player = Player()
        player.firstName = request.form['player_firstName']
        player.lastName = request.form['player_lastName']
        player.birthday = request.form['player_birthday']
        player.country = request.form['player_country']
        player.height = request.form['player_height']

        player = playerhandler.Insert(player)
        
        return redirect('/players')
    
    elif request.method == 'GET':
        return render_template('player_add.html', isAuthenticated = user_is_authenticated())
Ejemplo n.º 3
0
def player_update(key):
    if UserSession.currentUser is None:
        return redirect('/')
    
    if request.method == 'POST':
        player = Player()
        
        player.playerId = key
        player.firstName = request.form['player_firstName']
        player.lastName = request.form['player_lastName']
        player.birthday = request.form['player_birthday']
        player.country = request.form['player_country']
        player.height = request.form['player_height']

        player = playerhandler.Update(player)
        
        return redirect('/players')
    
    elif request.method == 'GET':
        current = playerhandler.GetByID(key)

        return render_template('player_update.html', currentPlayer=current, isAuthenticated = user_is_authenticated())