def league_api() -> Response:
    lg = league.active_league(should_load_decks=True)
    pdbot = request.form.get('api_token',
                             None) == configuration.get('pdbot_api_token')
    if not pdbot:
        lg.decks = [d for d in lg.decks if not d.is_in_current_run()]
    return return_json(lg)
Exemple #2
0
 def get(self) -> comp.Competition:
     lg = league.active_league(should_load_decks=True)
     pdbot = request.form.get('api_token',
                              None) == configuration.get('pdbot_api_token')
     if not pdbot:
         lg.decks = [d for d in lg.decks if not d.is_in_current_run()]
     return lg
Exemple #3
0
 def __init__(self):
     self.current = league.active_league()
     self.end_date = custom_strftime('%B {S}', self.current.end_date)
     self.signup_url = url_for('signup')
     self.report_url = url_for('report')
     self.records_url = url_for('current_league')
     self.retire_url = url_for('retire')
 def __init__(self) -> None:
     super().__init__()
     self.current = league.active_league()
     self.end_date = custom_strftime('%B {S}', self.current.end_date)
     self.signup_url = url_for('signup')
     self.report_url = url_for('report')
     self.records_url = url_for('current_league')
     self.retire_url = url_for('retire')
     self.bugs_url = url_for('tournaments', _anchor='bugs')
def ad_hoc() -> None:
    try:
        event_loop = asyncio.get_event_loop()
    except RuntimeError:
        event_loop = asyncio.new_event_loop()
        asyncio.set_event_loop(event_loop)

    league.set_status(league.Status.CLOSED)
    multiverse.init() # New Cards?
    event_loop.run_until_complete(multiverse.set_legal_cards_async()) # PD current list
    event_loop.run_until_complete(multiverse.update_pd_legality_async()) # PD previous lists
    insert_seasons.run() # Make sure Season table is up to date
    if redis.REDIS: # Clear the redis cache
        redis.REDIS.flushdb()
    league_end = league.active_league().end_date
    diff = league_end - dtutil.now()
    if diff.days > 0:
        league.set_status(league.Status.OPEN)
    print('Open the gates here')
    reprime_cache.run() # Update deck legalities
    if redis.REDIS: # Clear the redis cache
        redis.REDIS.flushdb()
def person_status() -> Response:
    username = auth.mtgo_username()
    r = {
        'mtgo_username': username,
        'discord_id': auth.discord_id(),
        'admin': session.get('admin', False),
        'demimod': session.get('demimod', False),
        'hide_intro': request.cookies.get('hide_intro', False) or auth.hide_intro() or username or auth.discord_id(),
        'in_guild': session.get('in_guild', False),
        }
    if username:
        d = guarantee_at_most_one_or_retire(league.active_decks_by(username))
        if d is not None:
            r['deck'] = {'name': d.name, 'url': url_for('deck', deck_id=d.id), 'wins': d.get('wins', 0), 'losses': d.get('losses', 0)} # type: ignore
    if r['admin'] or r['demimod']:
        r['archetypes_to_tag'] = len(deck.load_decks('NOT d.reviewed'))
    active_league = league.active_league()
    if active_league:
        time_until_league_end = active_league.end_date - datetime.datetime.now(tz=datetime.timezone.utc)
        if time_until_league_end <= datetime.timedelta(days=2):
            r['league_end'] = dtutil.display_time(time_until_league_end/datetime.timedelta(seconds=1), granularity=2)
    return return_json(r)
Exemple #7
0
def edit_matches() -> str:
    view = EditMatches(
        lg.active_league(should_load_decks=True).decks,
        lg.load_latest_league_matches())
    return view.page()
Exemple #8
0
def league_api():
    return return_json(league.active_league())
Exemple #9
0
def current_league() -> str:
    return competition(lg.active_league().id)
Exemple #10
0
 def __init__(self, form: Form) -> None:
     super().__init__()
     self.form = form
     self.league = league.active_league()
     self.competitions = [self.league]
Exemple #11
0
def current_league() -> wrappers.Response:
    url = url_for('competition', competition_id=lg.active_league().id)
    return redirect(url)
Exemple #12
0
 def __init__(self, form):
     self.form = form
     self.league = league.active_league()
     self.competitions = [self.league]
 def __init__(self, form):
     self.form = form
     self.league = league.active_league()
     self.competitions = [self.league]
     self.league_info_url = url_for('league')
Exemple #14
0
def league_api() -> Response:
    return return_json(league.active_league())