Update modules/ui.py
Browse files- modules/ui.py +23 -13
modules/ui.py
CHANGED
@@ -85,44 +85,52 @@ def login_form():
|
|
85 |
if st.button("Iniciar Sesi贸n"):
|
86 |
success, role = authenticate_user(username, password)
|
87 |
if success:
|
|
|
88 |
st.session_state.logged_in = True
|
89 |
st.session_state.username = username
|
90 |
st.session_state.role = role
|
91 |
-
print(f"Inicio de sesi贸n exitoso. Usuario: {username}, Rol: {role}")
|
92 |
-
st.
|
|
|
93 |
else:
|
94 |
st.error("Credenciales incorrectas")
|
95 |
-
|
|
|
96 |
##################################################################################################
|
|
|
97 |
def main():
|
98 |
if 'logged_in' not in st.session_state:
|
99 |
st.session_state.logged_in = False
|
100 |
|
|
|
|
|
101 |
if not st.session_state.logged_in:
|
102 |
login_register_page()
|
103 |
else:
|
104 |
-
print(f"
|
105 |
if st.session_state.role == 'Administrador':
|
106 |
-
print("
|
107 |
admin_page()
|
108 |
else:
|
109 |
-
print("
|
110 |
user_page()
|
|
|
|
|
|
|
111 |
##################################################################################################
|
112 |
def admin_page():
|
113 |
st.title("Panel de Administraci贸n")
|
|
|
114 |
|
115 |
-
# Crear nuevo usuario
|
116 |
-
st.header("Crear Nuevo Usuario")
|
117 |
new_username = st.text_input("Correo electr贸nico del nuevo usuario")
|
118 |
new_password = st.text_input("Contrase帽a", type="password")
|
119 |
if st.button("Crear Usuario"):
|
120 |
-
if
|
121 |
-
st.success(f"Usuario {new_username} creado exitosamente")
|
122 |
else:
|
123 |
-
st.error("Error al crear el usuario")
|
124 |
-
|
125 |
-
# Aqu铆 puedes a帽adir m谩s funcionalidades CRUD en el futuro
|
126 |
|
127 |
##################################################################################################
|
128 |
def register_form():
|
@@ -130,6 +138,7 @@ def register_form():
|
|
130 |
##
|
131 |
pass
|
132 |
##################################################################################################
|
|
|
133 |
def display_chat_interface():
|
134 |
st.markdown("### Chat con AIdeaText")
|
135 |
|
@@ -152,6 +161,7 @@ def display_chat_interface():
|
|
152 |
st.experimental_rerun()
|
153 |
|
154 |
##################################################################################################
|
|
|
155 |
def display_student_progress(username, lang_code='es'):
|
156 |
student_data = get_student_data(username)
|
157 |
|
|
|
85 |
if st.button("Iniciar Sesi贸n"):
|
86 |
success, role = authenticate_user(username, password)
|
87 |
if success:
|
88 |
+
st.session_state.clear() # Limpia la sesi贸n antes de establecer nuevos valores
|
89 |
st.session_state.logged_in = True
|
90 |
st.session_state.username = username
|
91 |
st.session_state.role = role
|
92 |
+
print(f"Inicio de sesi贸n exitoso. Usuario: {username}, Rol: {role}")
|
93 |
+
print(f"Estado de sesi贸n despu茅s de login: {st.session_state}") # Nuevo log
|
94 |
+
st.rerun() # Usa st.rerun() en lugar de st.experimental_rerun()
|
95 |
else:
|
96 |
st.error("Credenciales incorrectas")
|
97 |
+
|
98 |
+
|
99 |
##################################################################################################
|
100 |
+
|
101 |
def main():
|
102 |
if 'logged_in' not in st.session_state:
|
103 |
st.session_state.logged_in = False
|
104 |
|
105 |
+
print(f"Estado de sesi贸n al inicio de main: {st.session_state}") # Nuevo log
|
106 |
+
|
107 |
if not st.session_state.logged_in:
|
108 |
login_register_page()
|
109 |
else:
|
110 |
+
print(f"Usuario autenticado en main: {st.session_state.username}, Rol: {st.session_state.role}") # Log modificado
|
111 |
if st.session_state.role == 'Administrador':
|
112 |
+
print("Intentando mostrar p谩gina de administrador") # Nuevo log
|
113 |
admin_page()
|
114 |
else:
|
115 |
+
print(f"Mostrando p谩gina de usuario para rol: {st.session_state.role}") # Nuevo log
|
116 |
user_page()
|
117 |
+
|
118 |
+
print(f"Estado de sesi贸n al final de main: {st.session_state}") # Nuevo log
|
119 |
+
|
120 |
##################################################################################################
|
121 |
def admin_page():
|
122 |
st.title("Panel de Administraci贸n")
|
123 |
+
st.write(f"Bienvenido, {st.session_state.username}")
|
124 |
|
125 |
+
# Crear nuevo usuario estudiante
|
126 |
+
st.header("Crear Nuevo Usuario Estudiante")
|
127 |
new_username = st.text_input("Correo electr贸nico del nuevo usuario")
|
128 |
new_password = st.text_input("Contrase帽a", type="password")
|
129 |
if st.button("Crear Usuario"):
|
130 |
+
if create_student_user(new_username, new_password):
|
131 |
+
st.success(f"Usuario estudiante {new_username} creado exitosamente")
|
132 |
else:
|
133 |
+
st.error("Error al crear el usuario estudiante")
|
|
|
|
|
134 |
|
135 |
##################################################################################################
|
136 |
def register_form():
|
|
|
138 |
##
|
139 |
pass
|
140 |
##################################################################################################
|
141 |
+
|
142 |
def display_chat_interface():
|
143 |
st.markdown("### Chat con AIdeaText")
|
144 |
|
|
|
161 |
st.experimental_rerun()
|
162 |
|
163 |
##################################################################################################
|
164 |
+
|
165 |
def display_student_progress(username, lang_code='es'):
|
166 |
student_data = get_student_data(username)
|
167 |
|