Example #1
0
def viewTeam():
    hold = 123
    tt = 0
    tc = tm.select().count()

    while (hold == 123):
        t = tm.select().limit(5).offset(tt)
        print(
            '{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.format(
                'Team', 'Point Guard', 'Shooting Guard', 'Small Forward',
                'Power Forward', 'Center', 'Owner', 'Coach'))
        print('-' * 157)
        for team in t:
            print('{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.
                  format(team.tName, team.tPG, team.tSG, team.tSF, team.tPF,
                         team.tC, team.tOwner, team.tCoach))
        hold = input('\nNEXT[N]|END[X]: ')

        while (hold == 'n') or (hold == 'N'):
            os.system('cls')
            tt = tt + 5
            t = tm.select().limit(5).offset(tt)
            print('{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.
                  format('Team', 'Point Guard', 'Shooting Guard',
                         'Small Forward', 'Power Forward', 'Center', 'Owner',
                         'Coach'))
            print('-' * 160)
            for team in t:
                print(
                    '{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.
                    format(team.tName, team.tPG, team.tSG, team.tSF, team.tPF,
                           team.tC, team.tOwner, team.tCoach))
            hold = input('\nPREV[P]|NEXT[N]|END[X]: ')

            while (hold == 'p') or (hold == 'P'):
                os.system('cls')
                tt = tt - 5
                t = tm.select().limit(5).offset(tt)
                print(
                    '{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.
                    format('Team', 'Point Guard', 'Shooting Guard',
                           'Small Forward', 'Power Forward', 'Center', 'Owner',
                           'Coach'))
                print('-' * 160)
                for team in t:
                    print(
                        '{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'
                        .format(team.tName, team.tPG, team.tSG, team.tSF,
                                team.tPF, team.tC, team.tOwner, team.tCoach))
                hold = input('\nPREV[P]|NEXT[N]|END[X]: ')

                if (tt == 5) & (hold == 'p') or (hold == 'P'):
                    os.system('cls')
                    tt = 0
                    hold = 123

                elif tt < 0:
                    break
Example #2
0
def listTeam(cityid, schoolid):
    # Список городов и их дочерних школ, название текущего города и школы
    listCity   = City.select().order_by(City.cityName)
    listSchool = School.select().join(City).where(City.city_ID == cityid).order_by(School.schoolName)
    try:
        cityname   = City.get(city_ID = cityid).cityName
        schoolname = School.get(school_ID = schoolid).schoolName
    except DoesNotExist:
        cityname   = None
        schoolname = None

    # Список команд в выбранной школе
    listTeam = Team.select().join(School).where(School.school_ID == schoolid).join(City).where(City.city_ID == cityid).switch(Team).join(Age).order_by(Team.teamName)
    for lt in listTeam:
        lt.age_ID.ageName = int(date.today().year) - int(lt.age_ID.ageName)

    # Список возрастов по состоянию на текущий год
    listAge  = Age.select().order_by(Age.ageName)
    for age in listAge:
        age.ageName = int(date.today().year) - int(age.ageName)

    # Переменные для автозаполнения модальной формы добавления/обновления данных в JS-скрипте шаблона
    ## Список полей
    modifyFields = ['teamName', 'filterAge', 'ageName']
    ## Список групп радиокнопок
    modifyRadios = ['filterAge']
    ## Заголовки модального окна
    createHeader = ['"Создать новую юношескую команду"']
    updateHeader = ['"Изменить "', 'teamName', '" (возраст "', 'ageName', '")"']
    ## Действия формы
    createAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/create"']
    updateAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/"', 'PK_ID', '"/update"']
    deleteAction = ['"/city/"', cityid, '"/school/"', schoolid, '"/team/"', 'PK_ID', '"/delete"']

    # Вывод шаблона
    return render_template(
        'Team.jinja.html', 
        listCity     = listCity, 
        cityid       = cityid, 
        cityname     = cityname, 
        listSchool   = listSchool, 
        schoolid     = schoolid, 
        schoolname   = schoolname,
        listTeam     = listTeam,
        listAge      = listAge, 
        modifyFields = modifyFields,
        modifyRadios = modifyRadios,
        createHeader = createHeader,
        updateHeader = updateHeader,
        createAction = createAction,
        updateAction = updateAction,
        deleteAction = deleteAction)
Example #3
0
def searchTeam():
    teamN = input('Enter Team Name: ')
    t = tm.select().where(tm.tName.startswith(teamN))
    os.system('cls')
    print('{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.format(
        'Team', 'Point Guard', 'Shooting Guard', 'Small Forward',
        'Power Forward', 'Center', 'Owner', 'Coach'))
    print('-' * 160)
    for team in t:
        print(
            '{:<25s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}{:<20s}'.format(
                team.tName, team.tPG, team.tSG, team.tSF, team.tPF, team.tC,
                team.tOwner, team.tCoach))

    ctr = len(t)
    puts(colored.cyan('\nTotal No. of Teams: {}'.format(ctr)))
Example #4
0
def get_next_team(auction):
    taken_teams = []
    try:
        taken = Auction_result.select(
            Auction_result.team).where(Auction_result.auction == auction)
        for result in taken:
            taken_teams.append(result.team)
    except Auction_result.DoesNotExist:
        pass
    print(taken_teams)
    try:
        available_teams = Team.select().where(Team.team.not_in(taken_teams))
    except Team.DoesNotExist:
        return False
    print(available_teams)
    for team in available_teams:
        print(team)
    return random.choice(available_teams)
Example #5
0
def view():
    all_teams = Team.select()
    all_bids = Bid.select().where(Bid.team_bid == all_teams[0]).order_by(
        Bid.bid_amount)
    return render_template('view.jinja2', all_teams=all_teams, bids=all_bids)
Example #6
0
def start_the_auction(auction_name):
    global time_left
    auction = get_auction_obj(auction_name)
    available_teams = list(Team.select())
    while True:
        try:
            team_up_for_bids = random.choice(available_teams)
        except IndexError:
            Auction.update({
                Auction.current_team: None
            }).where(Auction.auction_name == auction_name).execute()
            Auction.update({
                Auction.complete: True
            }).where(Auction.auction_name == auction_name).execute()
            data = {
                'id': "bid-{}".format(uuid.uuid4().hex),
                'team': 'sale',
                'bidder': 'The Auction is Over!',
                'bid_amt': '',
                'status': 'active',
                'event_name': 'created',
                'reset': 1
            }
            pusher.trigger(auction_name, "bid-added", data)
            break
        available_teams.remove(team_up_for_bids)
        Auction.update({
            Auction.current_team: team_up_for_bids
        }).where(Auction.auction_name == auction_name).execute()
        data = {
            'id': "bid-{}".format(uuid.uuid4().hex),
            'team': 'sale',
            'bidder': 'Bidding Begins',
            'bid_amt': team_up_for_bids.team,
            'status': 'active',
            'event_name': 'created',
            'reset': 1
        }
        pusher.trigger(auction_name, "bid-added", data)
        time_left = 20
        while time_left > 0:
            data = {
                'id': "bid-{}".format(uuid.uuid4().hex),
                'time_remaining': time_left,
                'status': 'active',
                'event_name': 'created',
                'reset': 1
            }
            pusher.trigger(auction_name, "timing", data)
            time_left = time_left - 1
            sleep(1)
        data = {
            'id': "bid-{}".format(uuid.uuid4().hex),
            'time_remaining': time_left,
            'status': 'active',
            'event_name': 'created',
            'reset': 1
        }
        pusher.trigger(auction_name, "timing", data)
        data = {
            'id': "bid-{}".format(uuid.uuid4().hex),
            'team': 'sale',
            'bidder': 'Team sold!',
            'bid_amt': '',
            'status': 'active',
            'event_name': 'created',
            'reset': 1
        }
        pusher.trigger(auction_name, "bid-added", data)
        team_for_bid, high_bid, bid_leader = get_leader(auction)
        Auction_result.create(auction=auction,
                              team=team_up_for_bids,
                              buyer=bid_leader,
                              price=high_bid)
        sleep(3)
    return 'hooray'
Example #7
0
def listSAST(seasonid, ageid, sasid):
    # Список сезонов и возрастов по состоянию на текущий год, название текущего сезона и возраста, название и тип игровой стадии текущего игрового этапа
    listSeason = Season.select().order_by(Season.season_ID.asc())
    listAge = Age.select().order_by(Age.ageName)
    for age in listAge:
        age.ageName = int(date.today().year) - int(age.ageName)
    try:
        seasonname = Season.get(season_ID = seasonid).seasonName
        agename    = Age.get(age_ID = ageid).ageName
        sasname    = SAS.get(SAS_ID = sasid).stage_ID.stageName
        sastype    = SAS.get(SAS_ID = sasid).stage_ID.stageType
    except DoesNotExist:
        seasonname = None
        agename    = None
        sasname    = None
        sastype    = None

    # Список игровых этапов по типам
    listSAS_Z = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "Z").order_by(Stage.stageName)
    listSAS_G = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "G").order_by(Stage.stageName)
    listSAS_P = SAS.select().where(SAS.season_ID == seasonid, SAS.age_ID == ageid).join(Stage).where(Stage.stageType == "P").order_by(Stage.stageName)

    # Список городов, спортивных школ и команд для фильтрации по связанным выпадающим спискам
    filterCity   =   City.select().order_by(City.cityName)
    filterSchool = School.select().order_by(School.schoolName)
    filterTeam   =   Team.select().order_by(Team.teamName)

    # Список команд в текущем игровом этапе
    listSAST  = SAST.select().where(SAST.SAS_ID == sasid).join(Stage, JOIN_LEFT_OUTER).order_by(SAST.SAST_ID)
    # Список игровых стадий
    listStage = Stage.select().order_by(Stage.stageType, Stage.stageName).order_by(Stage.stage_ID)

    # Есть ли в текущем игровом этапе подгруппы
    is_SASTsubstage  = SAST.select().where(SAST.SAS_ID == sasid).join(Stage).exists()
    # Список подгрупп текущего игрового этапа (если они есть)
    listSASTsubstage = SAST.select(SAST.substage_ID).distinct().where(SAST.SAS_ID == sasid).join(Stage, JOIN_LEFT_OUTER)

    # Переменные для автозаполнения формы добавления/обновления данных в JS-скрипте шаблона
    ## Список полей
    modifyFields = ['filterCity', 'filterSchool', 'filterTeam', 'substage_ID', 'stageType', 'stageName']
    ## Список групп радиокнопок
    modifyRadios = ['substage_ID']
    ## Список выпадающих списков
    modifySelect = ['filterCity', 'filterSchool', 'filterTeam']   
    ## Заголовки модального окна
    createHeader = ['"Добавить команду в "', 'stageType', '" "', 'stageName']
    updateHeader = ['"Изменить команду, участвующую в "', 'stageType', '" "', 'stageName']
    ## Действия формы
    createAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/create"']
    updateAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/"', 'PK_ID', '"/update"']
    deleteAction = ['"/season/"', seasonid, '"/age/"', ageid, '"/stage/"', sasid, '"/team/"', 'PK_ID', '"/delete"']

    # Вывод шаблона
    return render_template(
        'SAST.jinja.html', 
        listSeason       = listSeason,
        seasonid         = seasonid,
        seasonname       = seasonname,
        listAge          = listAge,
        ageid            = ageid,
        agename          = agename,
        listSAS_Z        = listSAS_Z,
        listSAS_G        = listSAS_G,
        listSAS_P        = listSAS_P,
        sasid            = sasid,
        sasname          = sasname,
        sastype          = sastype,
        filterCity       = filterCity,
        filterSchool     = filterSchool,
        filterTeam       = filterTeam,
        listSAST         = listSAST,
        listStage        = listStage,
        is_SASTsubstage  = is_SASTsubstage,
        listSASTsubstage = listSASTsubstage,
        modifyFields     = modifyFields,
        modifyRadios     = modifyRadios,
        modifySelect     = modifySelect,
        createHeader     = createHeader,
        updateHeader     = updateHeader,
        createAction     = createAction,
        updateAction     = updateAction,
        deleteAction     = deleteAction)