Update modules/admin/admin_ui.py
Browse files- modules/admin/admin_ui.py +12 -1
modules/admin/admin_ui.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
#modules/admin/admin_ui.py
|
2 |
|
3 |
import streamlit as st
|
|
|
4 |
from datetime import datetime
|
|
|
5 |
from ..database.sql_db import (
|
6 |
get_user,
|
7 |
get_student_user,
|
@@ -15,8 +17,12 @@ from ..database.sql_db import (
|
|
15 |
get_recent_sessions,
|
16 |
get_user_total_time
|
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 +31,9 @@ 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}")
|
@@ -61,7 +70,9 @@ def admin_page():
|
|
61 |
if st.button("Crear Usuario", key="admin_create_user", type="primary"):
|
62 |
if new_username and new_password: # Verificamos que ambos campos tengan valor
|
63 |
try:
|
64 |
-
|
|
|
|
|
65 |
st.success(f"Usuario estudiante {new_username} creado exitosamente")
|
66 |
else:
|
67 |
st.error("Error al crear el usuario estudiante")
|
|
|
1 |
#modules/admin/admin_ui.py
|
2 |
|
3 |
import streamlit as st
|
4 |
+
|
5 |
from datetime import datetime
|
6 |
+
|
7 |
from ..database.sql_db import (
|
8 |
get_user,
|
9 |
get_student_user,
|
|
|
17 |
get_recent_sessions,
|
18 |
get_user_total_time
|
19 |
)
|
20 |
+
|
21 |
from ..database.morphosintax_mongo_db import get_student_morphosyntax_analysis
|
22 |
|
23 |
+
from ..auth.auth import hash_password # Agregar esta importaci贸n al inicio
|
24 |
+
|
25 |
+
########################################################
|
26 |
def format_duration(seconds):
|
27 |
"""Convierte segundos a formato legible"""
|
28 |
if not seconds:
|
|
|
31 |
minutes = (seconds % 3600) // 60
|
32 |
return f"{hours}h {minutes}m"
|
33 |
|
34 |
+
|
35 |
+
|
36 |
+
########################################################
|
37 |
def admin_page():
|
38 |
st.title("Panel de Administraci贸n")
|
39 |
st.write(f"Bienvenido, {st.session_state.username}")
|
|
|
70 |
if st.button("Crear Usuario", key="admin_create_user", type="primary"):
|
71 |
if new_username and new_password: # Verificamos que ambos campos tengan valor
|
72 |
try:
|
73 |
+
# Hashear la contrase帽a antes de crear el usuario
|
74 |
+
hashed_password = hash_password(new_password)
|
75 |
+
if create_student_user(new_username, hashed_password, {'partitionKey': new_username}):
|
76 |
st.success(f"Usuario estudiante {new_username} creado exitosamente")
|
77 |
else:
|
78 |
st.error("Error al crear el usuario estudiante")
|