import json from flask import session import sanitize import config_utils import factory def collect_tokens(cfg): tokens = config_utils.collect_layout_tokens(cfg) blank = [{'value': '', 'label': '-- Select Timezone --'}] tokens['PREF_EMAIL'] = session.get('email_address', '') tokens['PREF_TIMEZONE'] = session.get('timezone', '') tokens['TIMEZONE_OPTIONS'] = json.dumps(blank + [{'value': tz, 'label': tz} for tz in sanitize.VALID_TIMEZONES]) account = config_utils.get_account_by_id(session.get('account_id', '')) requested = (account or {}).get('requested_email', '') if requested: tokens['PENDING_EMAIL_BAR'] = ( f'
' f'A request to change email to {factory.e(requested)} is pending approval.' f'
' ) else: tokens['PENDING_EMAIL_BAR'] = '' return tokens