コード例 #1
0
def person_status():
    r = {
        'mtgo_username':
        auth.mtgo_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 auth.mtgo_username() or auth.discord_id(),
        'in_guild':
        session.get('in_guild', False),
    }
    if auth.mtgo_username():
        d = guarantee_at_most_one_or_retire(
            league.active_decks_by(auth.mtgo_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)
            }
    if r['admin'] or r['demimod']:
        r['archetypes_to_tag'] = len(deck.load_decks('NOT d.reviewed'))
    return return_json(r)
コード例 #2
0
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)
コード例 #3
0
def intro() -> Response:
    return return_json(not request.cookies.get('hide_intro', False)
                       and not auth.hide_intro())