Update modules/admin/admin_ui.py
Browse files- modules/admin/admin_ui.py +19 -0
modules/admin/admin_ui.py
CHANGED
@@ -17,6 +17,7 @@ from ..database.sql_db import (
|
|
17 |
)
|
18 |
from ..database.morphosintax_mongo_db import get_student_morphosyntax_analysis
|
19 |
|
|
|
20 |
def format_duration(seconds):
|
21 |
"""Convierte segundos a formato legible"""
|
22 |
if not seconds:
|
@@ -25,6 +26,7 @@ def format_duration(seconds):
|
|
25 |
minutes = (seconds % 3600) // 60
|
26 |
return f"{hours}h {minutes}m"
|
27 |
|
|
|
28 |
def admin_page():
|
29 |
st.title("Panel de Administraci贸n")
|
30 |
st.write(f"Bienvenido, {st.session_state.username}")
|
@@ -36,6 +38,23 @@ def admin_page():
|
|
36 |
"Actividad de la Plataforma"
|
37 |
])
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
############################################################################################
|
40 |
# Tab 1: Gesti贸n de Usuarios
|
41 |
|
|
|
17 |
)
|
18 |
from ..database.morphosintax_mongo_db import get_student_morphosyntax_analysis
|
19 |
|
20 |
+
##################################################################
|
21 |
def format_duration(seconds):
|
22 |
"""Convierte segundos a formato legible"""
|
23 |
if not seconds:
|
|
|
26 |
minutes = (seconds % 3600) // 60
|
27 |
return f"{hours}h {minutes}m"
|
28 |
|
29 |
+
########################################################################
|
30 |
def admin_page():
|
31 |
st.title("Panel de Administraci贸n")
|
32 |
st.write(f"Bienvenido, {st.session_state.username}")
|
|
|
38 |
"Actividad de la Plataforma"
|
39 |
])
|
40 |
|
41 |
+
new_username = st.text_input("Correo electr贸nico del nuevo usuario", key="admin_new_username")
|
42 |
+
new_password = st.text_input("Contrase帽a", type="password", key="admin_new_password")
|
43 |
+
|
44 |
+
if st.button("Crear Usuario", key="admin_create_user", type="primary"):
|
45 |
+
try:
|
46 |
+
# Hashear la contrase帽a antes de llamar a create_student_user
|
47 |
+
hashed_password = hash_password(new_password)
|
48 |
+
|
49 |
+
if create_student_user(new_username, hashed_password):
|
50 |
+
st.success(f"Usuario estudiante {new_username} creado exitosamente")
|
51 |
+
else:
|
52 |
+
st.error("Error al crear el usuario estudiante")
|
53 |
+
except Exception as e:
|
54 |
+
logger.error(f"Error en creaci贸n de usuario: {str(e)}")
|
55 |
+
st.error("Error al crear el usuario estudiante")
|
56 |
+
|
57 |
+
|
58 |
############################################################################################
|
59 |
# Tab 1: Gesti贸n de Usuarios
|
60 |
|