Spaces:
Running
Running
from streamlit.source_util import _on_pages_changed, get_pages | |
# Adapted from https://discuss.streamlit.io/t/how-to-hide-all-pages-before-login/32508 | |
# Note this code is intended to remove pages at app load time, not based on login | |
SEASON_MODE = "season" | |
OFFSEASON_MODE = "offseason" | |
CURRENT_MODE = SEASON_MODE | |
MAIN_PAGE_FILE = "Home.py" | |
MODE_PAGE_EXCLUSION_MAP = { | |
SEASON_MODE: [ | |
"Keepers", | |
"My_Keepers", | |
"Selected_Keepers", | |
"Draft_View", | |
"ECR", | |
"League_Simulation", | |
"Keeper_Rules", | |
"Maximum_Roster_Strategy", | |
], | |
OFFSEASON_MODE: [ | |
"Practice_Reports", | |
"League_Simulation", | |
"Maximum_Roster_Strategy", | |
"Targets", | |
"Redzone_Opportunities", | |
"Snap_Counts", | |
"FTN_Charting", | |
"Team_Formations", | |
"Next_Gen_Stats", | |
"Load_Data", | |
"Player_News", | |
# after keepers are selected | |
"My_Keepers", | |
], | |
} | |
def remove_seasonal_pages(): | |
all_pages = get_pages(MAIN_PAGE_FILE) | |
pages_to_remove = MODE_PAGE_EXCLUSION_MAP[CURRENT_MODE] | |
page_keys_to_remove = [] | |
for k, v in all_pages.items(): | |
if v["page_name"] in pages_to_remove: | |
page_keys_to_remove.append(k) | |
for k_remove in page_keys_to_remove: | |
del all_pages[k_remove] | |
_on_pages_changed.send() | |