コード例 #1
0
ファイル: server.py プロジェクト: sezenm/itucsdb1517
def hand_page(key=None,operation=None,error=None):
    if request.method == 'GET':
        if request.args.get('operation') == 'delete':
            store = hand_operations()
            result=store.delete_hand(request.args.get('key'))
            return redirect(url_for('admin.hand_page', error=result))
        else:
            store = hand_operations()
            hands=store.get_hands()
            now = datetime.datetime.now()
            error = request.args.get('error')
            return render_template('admin_hands.html', hands=hands, error=error, current_time=now.ctime())
    else:
        if request.form['submit']=='cancel':
            return redirect(url_for('admin.hand_page'))

        else:
            if request.form['key_value']=='':
                name = request.form['name']
                hand = Hand(None,name, 0)
                store = hand_operations()
                result=store.add_hand(hand)
                return redirect(url_for('admin.hand_page', error=result))
            else:
                name = request.form['name']
                key = request.form['key_value']
                store = hand_operations()
                result=store.update_hand(key, name)
                return redirect(url_for('admin.hand_page', error=result))
コード例 #2
0
ファイル: server.py プロジェクト: sezenm/itucsdb1517
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())
コード例 #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)
コード例 #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
コード例 #5
0
ファイル: server.py プロジェクト: sezenm/itucsdb1517
def hand_edit_page(key=None):
    store = hand_operations()
    hand = store.get_hand(key) if key is not None else None
    now = datetime.datetime.now()
    return render_template('hand_edit.html', hand=hand, current_time=now.ctime())