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

        else:
            if request.form['key_value']=='':
                type = request.form['name']
                gender = Gender(None,type, 0)
                store = gender_operations()
                result=store.add_gender(gender)
                return redirect(url_for('admin.gender_page', error=result))
            else:
                type = request.form['name']
                key = request.form['key_value']
                store = gender_operations()
                result=store.update_gender(key, type)
                return redirect(url_for('admin.gender_page', error=result))
コード例 #2
0
ファイル: server.py プロジェクト: sezenm/itucsdb1517
def coach_edit_page(key=None):
    store = coach_operations()
    storeTeam = team_operations()
    storeCountry = country_operations()
    storeGenders = gender_operations()
    coach = store.get_coach(key) if key is not None else None
    teams = storeTeam.get_teams()
    countries = storeCountry.get_countries()
    genders = storeGenders.get_genders()
    now = datetime.datetime.now()
    return render_template('coach_edit.html', coach=coach, teams=teams, countries=countries, genders=genders, current_time=now.ctime())
コード例 #3
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())
コード例 #4
0
    def get_coach(self, key):
        global connection
        storeCountry = country_operations()
        storeTeam = team_operations()
        storeGender = gender_operations()
        try:
            connection = dbapi2.connect(dsn)
            cursor = connection.cursor()
            statement = """SELECT objectid, name, surname,  countryid, teamid, birthday, genderid FROM coach where (objectid=%s and deleted=0)"""
            cursor.execute(statement, (key,))
            id,name,surname,countryid,teamid,birthyear,genderid=cursor.fetchone()
            cursor.close()
        except dbapi2.DatabaseError:
            if connection:
                connection.rollback()
        finally:
            if connection:
                connection.close()

        return Coach(id,name,surname,countryid, storeCountry.get_country(countryid), teamid, storeTeam.get_team(teamid), birthyear, genderid, storeGender.get_gender(genderid), 0)
コード例 #5
0
 def get_coaches(self):
     coachs=[]
     global connection
     storeCountry = country_operations()
     storeTeam = team_operations()
     storeGender = gender_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT coach.objectid, coach.name, coach.surname, coach.countryid, coach.teamid, coach.birthday, coach.genderid FROM coach WHERE coach.deleted = 0 ORDER BY objectid"""
         cursor.execute(statement)
         coachs = [(key, Coach(key,name,surname,countryid, storeCountry.get_country(countryid), teamid, storeTeam.get_team(teamid), birthyear, genderid, storeGender.get_gender(genderid), 0)) for key, name,surname, countryid, teamid, birthyear, genderid in cursor]
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return coachs
コード例 #6
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)
コード例 #7
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
コード例 #8
0
ファイル: server.py プロジェクト: sezenm/itucsdb1517
def gender_edit_page(key=None):
    store = gender_operations()
    gender = store.get_gender(key) if key is not None else None
    now = datetime.datetime.now()
    return render_template('gender_edit.html', gender=gender, current_time=now.ctime())