Пример #1
0
def season_page(key=None,operation=None,error=None):
    if request.method == 'GET':
        if request.args.get('operation') == 'delete':
            store = season_operations()
            result=store.delete_season(request.args.get('key'))
            return redirect(url_for('admin.season_page',error=result))
        else:
            store = season_operations()
            seasons=store.get_seasons()
            now = datetime.datetime.now()
            error = request.args.get('error')
            return render_template('admin_seasons.html', seasons=seasons, error=error, current_time=now.ctime())
    else:
        if request.form['submit']=='cancel':
            return redirect(url_for('admin.season_page'))

        else:
            if request.form['key_value']=='':
                name = request.form['name']
                season = Season(None,name, 0)
                store = season_operations()
                result=store.add_season(season)
                return redirect(url_for('admin.season_page', error=result))
            else:
                name = request.form['name']
                key = request.form['key_value']
                store = season_operations()
                result=store.update_season(key, name)
                return redirect(url_for('admin.season_page', error=result))
Пример #2
0
def statistic_edit_page(key=None):
    store = statistic_operations()
    storeSeason = season_operations()
    storePlayer = player_operations()
    statistic = store.get_statistic(key) if key is not None else None
    seasons = storeSeason.get_seasons()
    players = storePlayer.get_players()
    now = datetime.datetime.now()
    return render_template('statistic_edit.html', statistic=statistic, seasons=seasons,players=players, current_time=now.ctime())
Пример #3
0
def transfer_edit_page(key=None):
    store = transfer_operations()
    storeTeam = team_operations()
    storeSeason = season_operations()
    storePlayer = player_operations()
    transfer = store.get_transfer(key) if key is not None else None
    teams = storeTeam.get_teams()
    seasons = storeSeason.get_seasons()
    players = storePlayer.get_players()
    now = datetime.datetime.now()
    return render_template('transfer_edit.html', transfer=transfer, teams=teams,seasons=seasons,players=players, current_time=now.ctime())
Пример #4
0
 def get_statistic(self, key):
     global connection
     storeSeason = season_operations()
     storePlayer = player_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT objectid, assistnumber, blocknumber, score, cardnumber, seasonid, playerid FROM statistic where (objectid=%s and deleted=0)"""
         cursor.execute(statement, (key,))
         id,assistnumber,blocknumber, score, cardnumber, seasonid, playerid=cursor.fetchone()
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return Statistic(id, assistnumber, blocknumber, score, cardnumber, seasonid, storeSeason.get_season(seasonid), playerid, storePlayer.get_player(playerid), 0)
Пример #5
0
 def get_transfer(self, key):
     global connection
     storeTeam = team_operations()
     storeSeason = season_operations()
     storePlayer = player_operations()
     try:
         connection = dbapi2.connect(dsn)
         cursor = connection.cursor()
         statement = """SELECT objectid, playerid, oldteamid, newteamid, seasonid FROM transfer where (objectid=%s and deleted=0)"""
         cursor.execute(statement, (key,))
         id,playerid,oldteamid,newteamid,seasonid=cursor.fetchone()
         cursor.close()
     except dbapi2.DatabaseError:
         if connection:
             connection.rollback()
     finally:
         if connection:
             connection.close()
     return Transfer(id, playerid,storePlayer.get_player(playerid), oldteamid, storeTeam.get_team(oldteamid), newteamid, storeTeam.get_team(newteamid), seasonid, storeSeason.get_season(seasonid), 0)
Пример #6
0
    def get_statistics(self):
        global connection
        storeSeason = season_operations()
        storePlayer = player_operations()
        statistics=[]
        try:
            connection = dbapi2.connect(dsn)
            cursor = connection.cursor()
            statement = """SELECT statistic.objectid, statistic.assistnumber, statistic.blocknumber, statistic.score, statistic.cardnumber, statistic.seasonid, statistic.playerid FROM statistic where statistic.deleted=0 ORDER BY objectid"""
            cursor.execute(statement)
            statistics = [(key, Statistic(key, assistnumber, blocknumber,score, cardnumber, seasonid, storeSeason.get_season(seasonid), playerid, storePlayer.get_player(playerid), 0)) for key, assistnumber, blocknumber, score, cardnumber, seasonid, playerid in cursor]
            cursor.close()
        except dbapi2.DatabaseError:
            if connection:
                connection.rollback()
        finally:
            if connection:
                connection.close()

        return statistics
Пример #7
0
    def get_transfers(self):
        global connection
        storeTeam = team_operations()
        storeSeason = season_operations()
        storePlayer = player_operations()
        transfers=[]
        try:
            connection = dbapi2.connect(dsn)
            cursor = connection.cursor()
            statement = """SELECT transfer.objectid, transfer.playerid, transfer.oldteamid, transfer.newteamid, transfer.seasonid FROM transfer where transfer.deleted=0 ORDER BY objectid"""
            cursor.execute(statement)
            transfers = [(key, Transfer(key, playerid,storePlayer.get_player(playerid), oldteamid,storeTeam.get_team(oldteamid), newteamid, storeTeam.get_team(newteamid), seasonid, storeSeason.get_season(seasonid), 0)) for key, playerid, oldteamid, newteamid, seasonid in cursor]
            cursor.close()
        except dbapi2.DatabaseError:
            if connection:
                connection.rollback()
        finally:
            if connection:
                connection.close()

        return transfers
Пример #8
0
def season_edit_page(key=None):
    store = season_operations()
    season = store.get_season(key) if key is not None else None
    now = datetime.datetime.now()
    return render_template('season_edit.html', season=season, current_time=now.ctime())