Exemplo n.º 1
0
def position_page(key=None,operation=None,error=None):
    if request.method == 'GET':
        if request.args.get('operation') == 'delete':
            store = position_operations()
            result=store.delete_position(request.args.get('key'))
            return redirect(url_for('admin.position_page', error=result))
        else:
            store = position_operations()
            positions=store.get_positions()
            now = datetime.datetime.now()
            error = request.args.get('error')
            return render_template('admin_positions.html', positions=positions, error=error, current_time=now.ctime())
    else:
        if request.form['submit']=='cancel':
            return redirect(url_for('admin.position_page'))

        else:
            if request.form['key_value']=='':
                name = request.form['name']
                position = Position(None,name, 0)
                store = position_operations()
                result=store.add_position(position)
                return redirect(url_for('admin.position_page', error=result))
            else:
                name = request.form['name']
                key = request.form['key_value']
                store = position_operations()
                result=store.update_position(key, name)
                return redirect(url_for('admin.position_page', error=result))
Exemplo n.º 2
0
def player_edit_page(key=None):
    store = player_operations()
    storeCountry = country_operations()
    storeTeam = team_operations()
    storeGender = gender_operations()
    storePosition = position_operations()
    storeHand = hand_operations()

    player = store.get_player(key) if key is not None else None
    teams = storeTeam.get_teams()
    countries = storeCountry.get_countries()
    genders = storeGender.get_genders()
    positions = storePosition.get_positions()
    hands = storeHand.get_hands()

    now = datetime.datetime.now()
    return render_template('player_edit.html', player=player, teams=teams, countries=countries, genders=genders, positions=positions, hands=hands, current_time=now.ctime())
Exemplo n.º 3
0
    def get_player(self, key):
        global connection
        storeCountry = country_operations()
        storeTeam = team_operations()
        storeGender = gender_operations()
        storePosition = position_operations()
        storeHand = hand_operations()
        try:
            connection = dbapi2.connect(dsn)
            cursor = connection.cursor()
            statement = """SELECT objectid,name, surname, birthdate, height, weight, startdate, teamid, countryid, genderid, positionid, handid, number FROM player WHERE (objectid=%s and deleted=0)"""
            cursor.execute(statement, (key,))
            id,name,surname,birthdate,height,weight,startdate,teamid,countryid,genderid,positionid,handid,number=cursor.fetchone()
            cursor.close()
        except dbapi2.DatabaseError:
            if connection:
                connection.rollback()
        finally:
            if connection:
                connection.close()

        return Player(id, name, surname, birthdate, height, weight, startdate, teamid, storeTeam.get_team(teamid), countryid, storeCountry.get_country(countryid), genderid, storeGender.get_gender(genderid), positionid, storePosition.get_position(positionid), handid, storeHand.get_hand(handid), number, 0)
Exemplo n.º 4
0
 def get_players(self):
     players=[]
     global connection
     storeCountry = country_operations()
     storeTeam = team_operations()
     storeGender = gender_operations()
     storePosition = position_operations()
     storeHand = hand_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT objectid, name, surname, birthdate, height, weight, startdate, teamid, countryid, genderid, positionid, handid, number FROM player WHERE deleted = 0 ORDER BY objectid"""
         cursor.execute(statement)
         players = [(key, Player(key, name, surname, birthdate, height, weight, startdate, teamid, storeTeam.get_team(teamid),countryid, storeCountry.get_country(countryid), genderid, storeGender.get_gender(genderid), positionid, storePosition.get_position(positionid), handid, storeHand.get_hand(handid), number, 0)) for key, name, surname, birthdate, height, weight, startdate, teamid, countryid, genderid, positionid, handid, number in cursor]
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return players
Exemplo n.º 5
0
def position_edit_page(key=None):
    store = position_operations()
    position = store.get_position(key) if key is not None else None
    now = datetime.datetime.now()
    return render_template('position_edit.html', position=position, current_time=now.ctime())