Jon Solow commited on
Commit
7cf6c15
1 Parent(s): e26c359

Add league simulation page without functionality

Browse files
src/login_component.py CHANGED
@@ -23,11 +23,15 @@ ENABLE_LOGIN = os.environ.get("ENABLE_LOGIN", False)
23
  oauth2 = OAuth2Component(CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL, REFRESH_TOKEN_URL, REVOKE_TOKEN_URL)
24
 
25
 
 
 
 
 
26
  def get_authorization_button():
27
  if not ENABLE_LOGIN:
28
  return
29
  # Check if token exists in session state
30
- if "token" not in st.session_state:
31
  # If not, show authorize button
32
  result = oauth2.authorize_button("Login", REDIRECT_URI, SCOPE)
33
  if result and "token" in result:
 
23
  oauth2 = OAuth2Component(CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL, REFRESH_TOKEN_URL, REVOKE_TOKEN_URL)
24
 
25
 
26
+ def is_token_in_session() -> bool:
27
+ return "token" in st.session_state
28
+
29
+
30
  def get_authorization_button():
31
  if not ENABLE_LOGIN:
32
  return
33
  # Check if token exists in session state
34
+ if not is_token_in_session():
35
  # If not, show authorize button
36
  result = oauth2.authorize_button("Login", REDIRECT_URI, SCOPE)
37
  if result and "token" in result:
src/pages/11_League_Simulation.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import streamlit as st
3
+
4
+ from config import DEFAULT_ICON
5
+ from shared_page import common_page_config
6
+
7
+ from login_component import is_token_in_session
8
+
9
+ def get_page():
10
+ page_title = "Yahoo FF League Simulation"
11
+ st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
12
+ common_page_config()
13
+ st.title(page_title)
14
+
15
+ if not is_token_in_session():
16
+ st.write("You must be logged in to Yahoo Fantasy and authorize the application to access your account in order to use this feature. Please click Login button above.")
17
+
18
+ else:
19
+ st.write("Logged in. Feature to go here")
20
+
21
+
22
+ if __name__ == "__main__":
23
+ get_page()