Spaces:
Running
Running
Update modules/ui/ui.py
Browse files- modules/ui/ui.py +26 -343
modules/ui/ui.py
CHANGED
|
@@ -1,93 +1,32 @@
|
|
| 1 |
# modules/ui/ui.py
|
| 2 |
-
# Importaciones generales
|
| 3 |
import streamlit as st
|
| 4 |
from streamlit_player import st_player
|
| 5 |
import logging
|
| 6 |
-
from datetime import datetime
|
| 7 |
from dateutil.parser import parse
|
| 8 |
|
| 9 |
-
|
| 10 |
-
# Configuraci贸n del logger
|
| 11 |
-
logging.basicConfig(level=logging.INFO)
|
| 12 |
-
logger = logging.getLogger(__name__)
|
| 13 |
-
|
| 14 |
# Importaciones locales
|
| 15 |
-
|
| 16 |
from session_state import initialize_session_state, logout
|
| 17 |
-
|
| 18 |
from translations import get_translations
|
| 19 |
|
| 20 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
from ..admin.admin_ui import admin_page
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
from ..studentact.student_activities_v2 import display_student_activities
|
| 28 |
-
from ..studentact.current_situation_interface import display_current_situation_interface
|
| 29 |
-
from ..studentact.current_situation_analysis import analyze_text_dimensions
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
##Importaciones desde la configuraci贸n de bases datos #######
|
| 33 |
-
|
| 34 |
-
from ..database.sql_db import (
|
| 35 |
-
get_user,
|
| 36 |
-
get_admin_user,
|
| 37 |
-
get_student_user,
|
| 38 |
-
get_teacher_user,
|
| 39 |
-
create_user,
|
| 40 |
-
create_student_user,
|
| 41 |
-
create_teacher_user,
|
| 42 |
-
create_admin_user,
|
| 43 |
-
update_student_user, # Agregada
|
| 44 |
-
delete_student_user, # Agregada
|
| 45 |
-
record_login,
|
| 46 |
-
record_logout,
|
| 47 |
-
get_recent_sessions,
|
| 48 |
-
get_user_total_time,
|
| 49 |
-
store_application_request,
|
| 50 |
-
store_student_feedback
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
from ..database.mongo_db import (
|
| 54 |
-
get_collection,
|
| 55 |
-
insert_document,
|
| 56 |
-
find_documents,
|
| 57 |
-
update_document,
|
| 58 |
-
delete_document
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
from ..database.morphosintax_mongo_db import (
|
| 62 |
-
store_student_morphosyntax_result,
|
| 63 |
-
get_student_morphosyntax_analysis,
|
| 64 |
-
update_student_morphosyntax_analysis,
|
| 65 |
-
delete_student_morphosyntax_analysis,
|
| 66 |
-
get_student_morphosyntax_data
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
from ..database.chat_mongo_db import store_chat_history, get_chat_history
|
| 70 |
-
|
| 71 |
-
##Importaciones desde los an谩lisis #######
|
| 72 |
-
from ..morphosyntax.morphosyntax_interface import (
|
| 73 |
-
display_morphosyntax_interface,
|
| 74 |
-
display_arc_diagram
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
from ..semantic.semantic_interface import (
|
| 78 |
-
display_semantic_interface,
|
| 79 |
-
display_semantic_results
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
from ..semantic.semantic_live_interface import display_semantic_live_interface
|
| 83 |
-
|
| 84 |
-
from ..discourse.discourse_live_interface import display_discourse_live_interface
|
| 85 |
-
|
| 86 |
-
from ..discourse.discourse_interface import ( # Agregar esta importaci贸n
|
| 87 |
-
display_discourse_interface,
|
| 88 |
-
display_discourse_results
|
| 89 |
-
)
|
| 90 |
|
|
|
|
| 91 |
def main():
|
| 92 |
logger.info(f"Entrando en main() - P谩gina actual: {st.session_state.page}")
|
| 93 |
|
|
@@ -120,22 +59,6 @@ def main():
|
|
| 120 |
elif st.session_state.page == "Admin":
|
| 121 |
logger.info("Renderizando p谩gina de administrador")
|
| 122 |
admin_page()
|
| 123 |
-
|
| 124 |
-
elif st.session_state.page == "semantic":
|
| 125 |
-
# Si estamos en la p谩gina sem谩ntica, redirigir a la p谩gina de usuario
|
| 126 |
-
# pero mantener el tab seleccionado
|
| 127 |
-
logger.info("Redirigiendo p谩gina sem谩ntica a p谩gina de usuario")
|
| 128 |
-
st.session_state.page = 'user'
|
| 129 |
-
st.session_state.selected_tab = 1 # 铆ndice del tab sem谩ntico
|
| 130 |
-
st.rerun()
|
| 131 |
-
|
| 132 |
-
elif st.session_state.page == "morpho":
|
| 133 |
-
# Similar para la p谩gina morfosint谩ctica
|
| 134 |
-
logger.info("Redirigiendo p谩gina morfosint谩ctica a p谩gina de usuario")
|
| 135 |
-
st.session_state.page = 'user'
|
| 136 |
-
st.session_state.selected_tab = 0 # 铆ndice del tab morfosint谩ctico
|
| 137 |
-
st.rerun()
|
| 138 |
-
|
| 139 |
else:
|
| 140 |
logger.error(f"P谩gina no reconocida: {st.session_state.page}")
|
| 141 |
st.error(t.get('unrecognized_page', 'P谩gina no reconocida'))
|
|
@@ -145,6 +68,8 @@ def main():
|
|
| 145 |
|
| 146 |
logger.info(f"Saliendo de main() - Estado final de la sesi贸n: {st.session_state}")
|
| 147 |
|
|
|
|
|
|
|
| 148 |
def login_register_page(lang_code, t):
|
| 149 |
# st.title("AIdeaText")
|
| 150 |
# st.write(t.get("welcome_message", "Bienvenido. Por favor, inicie sesi贸n o reg铆strese."))
|
|
@@ -164,6 +89,8 @@ def login_register_page(lang_code, t):
|
|
| 164 |
with right_column:
|
| 165 |
display_videos_and_info(lang_code, t)
|
| 166 |
|
|
|
|
|
|
|
| 167 |
def login_form(lang_code, t):
|
| 168 |
with st.form("login_form"):
|
| 169 |
username = st.text_input(t.get("email", "Correo electr贸nico"))
|
|
@@ -185,6 +112,9 @@ def login_form(lang_code, t):
|
|
| 185 |
else:
|
| 186 |
st.error(t.get("invalid_credentials", "Credenciales incorrectas"))
|
| 187 |
|
|
|
|
|
|
|
|
|
|
| 188 |
def register_form(lang_code, t):
|
| 189 |
# st.header(t.get("request_trial", "Solicitar prueba de la aplicaci贸n"))
|
| 190 |
name = st.text_input(t.get("name", "Nombre"))
|
|
@@ -219,11 +149,16 @@ def register_form(lang_code, t):
|
|
| 219 |
st.error(t.get("application_error", "Hubo un problema al enviar tu solicitud. Por favor, intenta de nuevo m谩s tarde."))
|
| 220 |
logger.error(f"Failed to store application request for {email}")
|
| 221 |
|
|
|
|
|
|
|
|
|
|
| 222 |
def is_institutional_email(email):
|
| 223 |
forbidden_domains = ['gmail.com', 'hotmail.com', 'yahoo.com', 'outlook.com']
|
| 224 |
return not any(domain in email.lower() for domain in forbidden_domains)
|
| 225 |
|
| 226 |
|
|
|
|
|
|
|
| 227 |
def display_videos_and_info(lang_code, t):
|
| 228 |
# Crear tabs para cada secci贸n
|
| 229 |
tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
|
|
@@ -364,258 +299,6 @@ def display_videos_and_info(lang_code, t):
|
|
| 364 |
- Sistema de chat integrado para soporte
|
| 365 |
""")
|
| 366 |
|
| 367 |
-
#Despu茅s de iniciar sesi贸n
|
| 368 |
-
####################################
|
| 369 |
-
|
| 370 |
-
def user_page(lang_code, t):
|
| 371 |
-
logger.info(f"Entrando en user_page para el estudiante: {st.session_state.username}")
|
| 372 |
-
|
| 373 |
-
# Inicializar el tab seleccionado si no existe
|
| 374 |
-
if 'selected_tab' not in st.session_state:
|
| 375 |
-
st.session_state.selected_tab = 0
|
| 376 |
-
|
| 377 |
-
# Inicializar el estado del an谩lisis en vivo
|
| 378 |
-
if 'semantic_live_active' not in st.session_state:
|
| 379 |
-
st.session_state.semantic_live_active = False
|
| 380 |
-
|
| 381 |
-
# Manejar la carga inicial de datos del usuario
|
| 382 |
-
if 'user_data' not in st.session_state:
|
| 383 |
-
with st.spinner(t.get('loading_data', "Cargando tus datos...")):
|
| 384 |
-
try:
|
| 385 |
-
st.session_state.user_data = get_student_morphosyntax_data(st.session_state.username)
|
| 386 |
-
st.session_state.last_data_fetch = datetime.now(timezone.utc).isoformat()
|
| 387 |
-
except Exception as e:
|
| 388 |
-
logger.error(f"Error al obtener datos del usuario: {str(e)}")
|
| 389 |
-
st.error(t.get('data_load_error', "Hubo un problema al cargar tus datos. Por favor, intenta recargar la p谩gina."))
|
| 390 |
-
return
|
| 391 |
-
|
| 392 |
-
logger.info(f"Idioma actual: {st.session_state.lang_code}")
|
| 393 |
-
logger.info(f"Modelos NLP cargados: {'nlp_models' in st.session_state}")
|
| 394 |
-
|
| 395 |
-
# Configuraci贸n de idiomas disponibles
|
| 396 |
-
languages = {'Espa帽ol': 'es', 'English': 'en', 'Fran莽ais': 'fr'}
|
| 397 |
-
|
| 398 |
-
# Estilos CSS personalizados
|
| 399 |
-
st.markdown("""
|
| 400 |
-
<style>
|
| 401 |
-
.stSelectbox > div > div {
|
| 402 |
-
padding-top: 0px;
|
| 403 |
-
}
|
| 404 |
-
.stButton > button {
|
| 405 |
-
padding-top: 2px;
|
| 406 |
-
margin-top: 0px;
|
| 407 |
-
}
|
| 408 |
-
div[data-testid="stHorizontalBlock"] > div:nth-child(3) {
|
| 409 |
-
display: flex;
|
| 410 |
-
justify-content: flex-end;
|
| 411 |
-
align-items: center;
|
| 412 |
-
}
|
| 413 |
-
</style>
|
| 414 |
-
""", unsafe_allow_html=True)
|
| 415 |
-
|
| 416 |
-
# Barra superior con informaci贸n del usuario y controles
|
| 417 |
-
with st.container():
|
| 418 |
-
col1, col2, col3 = st.columns([2, 2, 1])
|
| 419 |
-
with col1:
|
| 420 |
-
st.markdown(f"<h3 style='margin-bottom: 0; padding-top: 10px;'>{t['welcome']}, {st.session_state.username}</h3>",
|
| 421 |
-
unsafe_allow_html=True)
|
| 422 |
-
with col2:
|
| 423 |
-
selected_lang = st.selectbox(
|
| 424 |
-
t['select_language'],
|
| 425 |
-
list(languages.keys()),
|
| 426 |
-
index=list(languages.values()).index(st.session_state.lang_code),
|
| 427 |
-
key=f"language_selector_{st.session_state.username}_{st.session_state.lang_code}"
|
| 428 |
-
)
|
| 429 |
-
new_lang_code = languages[selected_lang]
|
| 430 |
-
if st.session_state.lang_code != new_lang_code:
|
| 431 |
-
st.session_state.lang_code = new_lang_code
|
| 432 |
-
st.rerun()
|
| 433 |
-
with col3:
|
| 434 |
-
if st.button(t['logout'],
|
| 435 |
-
key=f"logout_button_{st.session_state.username}_{st.session_state.lang_code}"):
|
| 436 |
-
st.session_state.clear()
|
| 437 |
-
st.rerun()
|
| 438 |
-
|
| 439 |
-
st.markdown("---")
|
| 440 |
-
|
| 441 |
-
# Asegurarse de que tenemos las traducciones del chatbot
|
| 442 |
-
chatbot_t = t.get('CHATBOT_TRANSLATIONS', {}).get(lang_code, {})
|
| 443 |
-
|
| 444 |
-
# Mostrar chatbot en sidebar
|
| 445 |
-
display_sidebar_chat(lang_code, chatbot_t)
|
| 446 |
-
|
| 447 |
-
# Inicializar estados para todos los tabs
|
| 448 |
-
if 'tab_states' not in st.session_state:
|
| 449 |
-
st.session_state.tab_states = {
|
| 450 |
-
'current_situation_active': False,
|
| 451 |
-
'morpho_active': False,
|
| 452 |
-
'semantic_live_active': False,
|
| 453 |
-
'semantic_active': False,
|
| 454 |
-
'discourse_live_active': False,
|
| 455 |
-
'discourse_active': False,
|
| 456 |
-
'activities_active': False,
|
| 457 |
-
'feedback_active': False
|
| 458 |
-
}
|
| 459 |
-
|
| 460 |
-
# Sistema de tabs
|
| 461 |
-
tab_names = [
|
| 462 |
-
t.get('current_situation_tab', "Mi Situaci贸n Actual"),
|
| 463 |
-
t.get('morpho_tab', 'An谩lisis Morfosint谩ctico'),
|
| 464 |
-
t.get('semantic_live_tab', 'An谩lisis Sem谩ntico Vivo'),
|
| 465 |
-
t.get('semantic_tab', 'An谩lisis Sem谩ntico'),
|
| 466 |
-
t.get('discourse_live_tab', 'An谩lisis de Discurso Vivo'),
|
| 467 |
-
t.get('discourse_tab', 'An谩lsis de Discurso'),
|
| 468 |
-
t.get('activities_tab', 'Mis Actividades'),
|
| 469 |
-
t.get('feedback_tab', 'Formulario de Comentarios')
|
| 470 |
-
]
|
| 471 |
-
|
| 472 |
-
tabs = st.tabs(tab_names)
|
| 473 |
-
|
| 474 |
-
# Manejar el contenido de cada tab
|
| 475 |
-
for index, tab in enumerate(tabs):
|
| 476 |
-
with tab:
|
| 477 |
-
try:
|
| 478 |
-
# Actualizar el tab seleccionado solo si no hay un an谩lisis activo
|
| 479 |
-
if tab.selected and st.session_state.selected_tab != index:
|
| 480 |
-
can_switch = True
|
| 481 |
-
for state_key in st.session_state.tab_states.keys():
|
| 482 |
-
if st.session_state.tab_states[state_key] and index != get_tab_index(state_key):
|
| 483 |
-
can_switch = False
|
| 484 |
-
break
|
| 485 |
-
if can_switch:
|
| 486 |
-
st.session_state.selected_tab = index
|
| 487 |
-
|
| 488 |
-
if index == 0: # Situaci贸n actual
|
| 489 |
-
st.session_state.tab_states['current_situation_active'] = True
|
| 490 |
-
display_current_situation_interface(
|
| 491 |
-
st.session_state.lang_code,
|
| 492 |
-
st.session_state.nlp_models,
|
| 493 |
-
t.get('TRANSLATIONS', {})
|
| 494 |
-
)
|
| 495 |
-
|
| 496 |
-
elif index == 1: # Morfosint谩ctico
|
| 497 |
-
st.session_state.tab_states['morpho_active'] = True
|
| 498 |
-
display_morphosyntax_interface(
|
| 499 |
-
st.session_state.lang_code,
|
| 500 |
-
st.session_state.nlp_models,
|
| 501 |
-
t.get('TRANSLATIONS', {})
|
| 502 |
-
)
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
elif index == 2: # Sem谩ntico Vivo
|
| 506 |
-
st.session_state.tab_states['semantic_live_active'] = True
|
| 507 |
-
display_semantic_live_interface(
|
| 508 |
-
st.session_state.lang_code,
|
| 509 |
-
st.session_state.nlp_models,
|
| 510 |
-
t.get('TRANSLATIONS', {})
|
| 511 |
-
)
|
| 512 |
-
|
| 513 |
-
elif index == 3: # Sem谩ntico
|
| 514 |
-
st.session_state.tab_states['semantic_active'] = True
|
| 515 |
-
display_semantic_interface(
|
| 516 |
-
st.session_state.lang_code,
|
| 517 |
-
st.session_state.nlp_models,
|
| 518 |
-
t.get('TRANSLATIONS', {})
|
| 519 |
-
)
|
| 520 |
-
|
| 521 |
-
elif index == 4: # Discurso Vivo
|
| 522 |
-
st.session_state.tab_states['discourse_live_active'] = True
|
| 523 |
-
display_discourse_live_interface(
|
| 524 |
-
st.session_state.lang_code,
|
| 525 |
-
st.session_state.nlp_models,
|
| 526 |
-
t.get('TRANSLATIONS', {})
|
| 527 |
-
)
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
elif index == 5: # Discurso
|
| 531 |
-
st.session_state.tab_states['discourse_active'] = True
|
| 532 |
-
display_discourse_interface(
|
| 533 |
-
st.session_state.lang_code,
|
| 534 |
-
st.session_state.nlp_models,
|
| 535 |
-
t.get('TRANSLATIONS', {})
|
| 536 |
-
)
|
| 537 |
-
|
| 538 |
-
elif index == 6: # Actividades
|
| 539 |
-
st.session_state.tab_states['activities_active'] = True
|
| 540 |
-
display_student_activities(
|
| 541 |
-
username=st.session_state.username,
|
| 542 |
-
lang_code=st.session_state.lang_code,
|
| 543 |
-
t=t.get('ACTIVITIES_TRANSLATIONS', {})
|
| 544 |
-
)
|
| 545 |
-
|
| 546 |
-
elif index == 7: # Feedback
|
| 547 |
-
st.session_state.tab_states['feedback_active'] = True
|
| 548 |
-
display_feedback_form(
|
| 549 |
-
st.session_state.lang_code,
|
| 550 |
-
t
|
| 551 |
-
)
|
| 552 |
-
|
| 553 |
-
except Exception as e:
|
| 554 |
-
# Desactivar el estado en caso de error
|
| 555 |
-
state_key = get_state_key_for_index(index)
|
| 556 |
-
if state_key:
|
| 557 |
-
st.session_state.tab_states[state_key] = False
|
| 558 |
-
logger.error(f"Error en tab {index}: {str(e)}")
|
| 559 |
-
st.error(t.get('tab_error', 'Error al cargar esta secci贸n'))
|
| 560 |
-
|
| 561 |
-
# Funciones auxiliares para manejar los estados de los tabs
|
| 562 |
-
def get_tab_index(state_key):
|
| 563 |
-
"""Obtiene el 铆ndice del tab basado en la clave de estado"""
|
| 564 |
-
index_map = {
|
| 565 |
-
'current_situation_active': 0,
|
| 566 |
-
'morpho_active': 1,
|
| 567 |
-
'semantic_live_active': 2,
|
| 568 |
-
'semantic_active': 3,
|
| 569 |
-
'discourse_live_active': 4,
|
| 570 |
-
'discourse_active': 5,
|
| 571 |
-
'activities_active': 6,
|
| 572 |
-
'feedback_active': 7
|
| 573 |
-
}
|
| 574 |
-
return index_map.get(state_key, -1)
|
| 575 |
-
|
| 576 |
-
def get_state_key_for_index(index):
|
| 577 |
-
"""Obtiene la clave de estado basada en el 铆ndice del tab"""
|
| 578 |
-
state_map = {
|
| 579 |
-
0: 'current_situation_active',
|
| 580 |
-
1: 'morpho_active',
|
| 581 |
-
2: 'semantic_live_active',
|
| 582 |
-
3: 'semantic_active',
|
| 583 |
-
4: 'discourse_live_active',
|
| 584 |
-
5: 'discourse_active',
|
| 585 |
-
6: 'activities_active',
|
| 586 |
-
7: 'feedback_active'
|
| 587 |
-
}
|
| 588 |
-
return state_map.get(index)
|
| 589 |
-
|
| 590 |
-
# Panel de depuraci贸n (solo visible en desarrollo)
|
| 591 |
-
if st.session_state.get('debug_mode', False):
|
| 592 |
-
with st.expander("Debug Info"):
|
| 593 |
-
st.write(f"P谩gina actual: {st.session_state.page}")
|
| 594 |
-
st.write(f"Usuario: {st.session_state.get('username', 'No logueado')}")
|
| 595 |
-
st.write(f"Rol: {st.session_state.get('role', 'No definido')}")
|
| 596 |
-
st.write(f"Idioma: {st.session_state.lang_code}")
|
| 597 |
-
st.write(f"Tab seleccionado: {st.session_state.selected_tab}")
|
| 598 |
-
st.write(f"脷ltima actualizaci贸n de datos: {st.session_state.get('last_data_fetch', 'Nunca')}")
|
| 599 |
-
|
| 600 |
-
########################################################################
|
| 601 |
-
def display_feedback_form(lang_code, t):
|
| 602 |
-
logging.info(f"display_feedback_form called with lang_code: {lang_code}")
|
| 603 |
-
|
| 604 |
-
st.header(t['feedback_title'])
|
| 605 |
-
|
| 606 |
-
name = st.text_input(t['name'])
|
| 607 |
-
email = st.text_input(t['email'])
|
| 608 |
-
feedback = st.text_area(t['feedback'])
|
| 609 |
-
|
| 610 |
-
if st.button(t['submit']):
|
| 611 |
-
if name and email and feedback:
|
| 612 |
-
if store_student_feedback(st.session_state.username, name, email, feedback):
|
| 613 |
-
st.success(t['feedback_success'])
|
| 614 |
-
else:
|
| 615 |
-
st.error(t['feedback_error'])
|
| 616 |
-
else:
|
| 617 |
-
st.warning(t['complete_all_fields'])
|
| 618 |
-
|
| 619 |
# Definici贸n de __all__ para especificar qu茅 se exporta
|
| 620 |
__all__ = ['main', 'login_register_page', 'initialize_session_state']
|
| 621 |
|
|
|
|
| 1 |
# modules/ui/ui.py
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from streamlit_player import st_player
|
| 4 |
import logging
|
| 5 |
+
from datetime import datetime
|
| 6 |
from dateutil.parser import parse
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Importaciones locales
|
|
|
|
| 9 |
from session_state import initialize_session_state, logout
|
|
|
|
| 10 |
from translations import get_translations
|
| 11 |
|
| 12 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 13 |
|
| 14 |
+
#from .user_page import user_page
|
| 15 |
+
try:
|
| 16 |
+
from .user_page import user_page
|
| 17 |
+
except ImportError:
|
| 18 |
+
logger.error("No se pudo importar user_page. Aseg煤rate de que el archivo existe.")
|
| 19 |
+
# Definir una funci贸n de respaldo
|
| 20 |
+
def user_page(lang_code, t):
|
| 21 |
+
st.error("La p谩gina de usuario no est谩 disponible. Por favor, contacta al administrador.")
|
| 22 |
+
|
| 23 |
from ..admin.admin_ui import admin_page
|
| 24 |
|
| 25 |
+
# Configuraci贸n del logger
|
| 26 |
+
logging.basicConfig(level=logging.INFO)
|
| 27 |
+
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
#############################################################
|
| 30 |
def main():
|
| 31 |
logger.info(f"Entrando en main() - P谩gina actual: {st.session_state.page}")
|
| 32 |
|
|
|
|
| 59 |
elif st.session_state.page == "Admin":
|
| 60 |
logger.info("Renderizando p谩gina de administrador")
|
| 61 |
admin_page()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
else:
|
| 63 |
logger.error(f"P谩gina no reconocida: {st.session_state.page}")
|
| 64 |
st.error(t.get('unrecognized_page', 'P谩gina no reconocida'))
|
|
|
|
| 68 |
|
| 69 |
logger.info(f"Saliendo de main() - Estado final de la sesi贸n: {st.session_state}")
|
| 70 |
|
| 71 |
+
#############################################################
|
| 72 |
+
#############################################################
|
| 73 |
def login_register_page(lang_code, t):
|
| 74 |
# st.title("AIdeaText")
|
| 75 |
# st.write(t.get("welcome_message", "Bienvenido. Por favor, inicie sesi贸n o reg铆strese."))
|
|
|
|
| 89 |
with right_column:
|
| 90 |
display_videos_and_info(lang_code, t)
|
| 91 |
|
| 92 |
+
#############################################################
|
| 93 |
+
#############################################################
|
| 94 |
def login_form(lang_code, t):
|
| 95 |
with st.form("login_form"):
|
| 96 |
username = st.text_input(t.get("email", "Correo electr贸nico"))
|
|
|
|
| 112 |
else:
|
| 113 |
st.error(t.get("invalid_credentials", "Credenciales incorrectas"))
|
| 114 |
|
| 115 |
+
|
| 116 |
+
#############################################################
|
| 117 |
+
#############################################################
|
| 118 |
def register_form(lang_code, t):
|
| 119 |
# st.header(t.get("request_trial", "Solicitar prueba de la aplicaci贸n"))
|
| 120 |
name = st.text_input(t.get("name", "Nombre"))
|
|
|
|
| 149 |
st.error(t.get("application_error", "Hubo un problema al enviar tu solicitud. Por favor, intenta de nuevo m谩s tarde."))
|
| 150 |
logger.error(f"Failed to store application request for {email}")
|
| 151 |
|
| 152 |
+
|
| 153 |
+
#############################################################
|
| 154 |
+
#############################################################
|
| 155 |
def is_institutional_email(email):
|
| 156 |
forbidden_domains = ['gmail.com', 'hotmail.com', 'yahoo.com', 'outlook.com']
|
| 157 |
return not any(domain in email.lower() for domain in forbidden_domains)
|
| 158 |
|
| 159 |
|
| 160 |
+
#############################################################
|
| 161 |
+
#############################################################
|
| 162 |
def display_videos_and_info(lang_code, t):
|
| 163 |
# Crear tabs para cada secci贸n
|
| 164 |
tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
|
|
|
|
| 299 |
- Sistema de chat integrado para soporte
|
| 300 |
""")
|
| 301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
# Definici贸n de __all__ para especificar qu茅 se exporta
|
| 303 |
__all__ = ['main', 'login_register_page', 'initialize_session_state']
|
| 304 |
|