James McCool commited on
Commit
e793d80
·
1 Parent(s): 41efef4

Refactor contest file upload logic in app.py for improved clarity and functionality

Browse files

- Moved the manual upload option to ensure it is processed after the DB search option, enhancing user experience.
- Ensured that the session state for 'Contest_file' is properly managed during manual uploads, maintaining data integrity and clarity in the loading process.

Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -67,16 +67,15 @@ with tab1:
67
  st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
68
  if parse_type == 'DB Search':
69
  contest_name_var = st.selectbox("Select Contest to load", contest_names)
70
- elif parse_type == 'Manual':
71
- st.session_state['Contest_file'] = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
72
- if 'Contest' in st.session_state:
73
- del st.session_state['Contest']
74
- if parse_type == 'DB Search':
75
  if 'Contest_file' not in st.session_state:
76
  if st.button('Load Contest Data', key='load_contest_data'):
77
  st.session_state['Contest_file'] = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
78
  else:
79
  pass
 
 
 
 
80
 
81
  if 'Contest_file' not in st.session_state and 'Adj_Contest' not in st.session_state:
82
  st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(st.session_state['Contest_file'], sport_select)
 
67
  st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
68
  if parse_type == 'DB Search':
69
  contest_name_var = st.selectbox("Select Contest to load", contest_names)
 
 
 
 
 
70
  if 'Contest_file' not in st.session_state:
71
  if st.button('Load Contest Data', key='load_contest_data'):
72
  st.session_state['Contest_file'] = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
73
  else:
74
  pass
75
+ elif parse_type == 'Manual':
76
+ st.session_state['Contest_file'] = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
77
+ if 'Contest' in st.session_state:
78
+ del st.session_state['Contest']
79
 
80
  if 'Contest_file' not in st.session_state and 'Adj_Contest' not in st.session_state:
81
  st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(st.session_state['Contest_file'], sport_select)