Пример #1
0
def Get(filterExpression = None):
    connection, cursor = basehandler.DbConnect()

    myQuery = "SELECT * FROM CAREERS_DBT"

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

    careerList = []

    for career in cursor.fetchall():
        tempCareer = Career()

        tempCareer.careerId = career[0]
        tempCareer.playerId = career[1]
        tempCareer.biography = career[2]
        tempCareer.olympicGames = career[3]
        tempCareer.singlesHighestRanking = career[4]
        tempCareer.doublesHighestRanking = career[5]


        careerList.append(tempCareer)

    basehandler.DbClose(connection, cursor)

    return careerList
Пример #2
0
def career_update(key):
    if UserSession.currentUser is None:
        return redirect('/')
    
    if request.method == 'POST':
        career = Career()
        
        career.careerId = key
        career.biography = request.form['career_biography']
        career.olympicGames = request.form['career_olympicGames']
        career.singlesHighestRanking = request.form['career_singles']
        career.doublesHighestRanking = request.form['career_doubles']
        career.playerId = request.form['career_playerId']

        career = careerhandler.Update(career)
        
        tempUrl = "/player/" + str(key)
        
        return redirect(tempUrl)
    
    elif request.method == 'GET':
        current = careerhandler.GetByID(key)

        return render_template('career_update.html', currentCareer=current, isAuthenticated = user_is_authenticated())