Update modules/ui/ui.py
Browse files- modules/ui/ui.py +45 -30
modules/ui/ui.py
CHANGED
|
@@ -136,18 +136,19 @@ def show_carousel():
|
|
| 136 |
logger.error(f"Error en show_carousel: {str(e)}")
|
| 137 |
|
| 138 |
#########################################################
|
| 139 |
-
|
| 140 |
-
|
| 141 |
# Configura el logger PRIMERO, antes de cualquier uso
|
| 142 |
logging.basicConfig(level=logging.INFO)
|
| 143 |
logger = logging.getLogger(__name__)
|
| 144 |
|
|
|
|
| 145 |
# Importaciones locales
|
| 146 |
from session_state import initialize_session_state, logout
|
| 147 |
from translations import get_translations, get_landing_translations
|
| 148 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 149 |
from ..database.sql_db import store_application_request
|
|
|
|
| 150 |
|
|
|
|
| 151 |
# Intento de importación con logger YA DEFINIDO
|
| 152 |
try:
|
| 153 |
from .user_page import user_page
|
|
@@ -158,8 +159,6 @@ except ImportError as e:
|
|
| 158 |
def user_page(lang_code, t):
|
| 159 |
st.error("La página de usuario no está disponible. Por favor, contacta al administrador.")
|
| 160 |
|
| 161 |
-
from ..admin.admin_ui import admin_page
|
| 162 |
-
|
| 163 |
#############################################################
|
| 164 |
def main():
|
| 165 |
logger.info(f"Entrando en main() - Página actual: {st.session_state.page}")
|
|
@@ -324,38 +323,54 @@ def login_form(lang_code, landing_t):
|
|
| 324 |
#############################################################
|
| 325 |
#############################################################
|
| 326 |
def register_form(lang_code, landing_t):
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
institution = st.text_input(landing_t['institution'])
|
| 330 |
-
current_role = st.selectbox(landing_t['current_role'],
|
| 331 |
-
[landing_t['professor'], landing_t['student'], landing_t['administrative']])
|
| 332 |
|
| 333 |
-
#
|
| 334 |
-
|
|
|
|
|
|
|
| 335 |
|
| 336 |
-
|
| 337 |
-
reason = st.text_area(
|
| 338 |
|
| 339 |
-
|
|
|
|
| 340 |
logger.info(f"Intentando enviar solicitud para {email}")
|
| 341 |
-
logger.debug(f"Datos del formulario: name={name}, lastname={lastname}, email={email}, institution={institution}, current_role={current_role}, desired_role={desired_role}, reason={reason}")
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
st.error(
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
else:
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
if success:
|
| 353 |
-
st.success(landing_t['application_sent'])
|
| 354 |
-
logger.info(f"Solicitud almacenada exitosamente para {email}")
|
| 355 |
-
else:
|
| 356 |
-
st.error(landing_t['application_error'])
|
| 357 |
-
logger.error(f"Error al almacenar solicitud para {email}")
|
| 358 |
-
|
| 359 |
|
| 360 |
#############################################################
|
| 361 |
#############################################################
|
|
|
|
| 136 |
logger.error(f"Error en show_carousel: {str(e)}")
|
| 137 |
|
| 138 |
#########################################################
|
|
|
|
|
|
|
| 139 |
# Configura el logger PRIMERO, antes de cualquier uso
|
| 140 |
logging.basicConfig(level=logging.INFO)
|
| 141 |
logger = logging.getLogger(__name__)
|
| 142 |
|
| 143 |
+
#########################################################
|
| 144 |
# Importaciones locales
|
| 145 |
from session_state import initialize_session_state, logout
|
| 146 |
from translations import get_translations, get_landing_translations
|
| 147 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 148 |
from ..database.sql_db import store_application_request
|
| 149 |
+
from ..admin.admin_ui import admin_page
|
| 150 |
|
| 151 |
+
#########################################################
|
| 152 |
# Intento de importación con logger YA DEFINIDO
|
| 153 |
try:
|
| 154 |
from .user_page import user_page
|
|
|
|
| 159 |
def user_page(lang_code, t):
|
| 160 |
st.error("La página de usuario no está disponible. Por favor, contacta al administrador.")
|
| 161 |
|
|
|
|
|
|
|
| 162 |
#############################################################
|
| 163 |
def main():
|
| 164 |
logger.info(f"Entrando en main() - Página actual: {st.session_state.page}")
|
|
|
|
| 323 |
#############################################################
|
| 324 |
#############################################################
|
| 325 |
def register_form(lang_code, landing_t):
|
| 326 |
+
"""Formulario de registro simplificado - SOLO 3 CAMPOS"""
|
| 327 |
+
st.markdown("#### 🚀 Nuevo Usuario")
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
+
# Solo 3 campos requeridos
|
| 330 |
+
name = st.text_input("Nombre completo *")
|
| 331 |
+
email = st.text_input("Correo institucional *")
|
| 332 |
+
institution = st.text_input("Institución educativa *")
|
| 333 |
|
| 334 |
+
# Campo opcional para motivo de interés
|
| 335 |
+
reason = st.text_area("¿Por qué te interesa AIdeaText? (Opcional)")
|
| 336 |
|
| 337 |
+
# Botón simplificado
|
| 338 |
+
if st.button(landing_t['submit_application'], type="primary"):
|
| 339 |
logger.info(f"Intentando enviar solicitud para {email}")
|
|
|
|
| 340 |
|
| 341 |
+
# Validaciones básicas
|
| 342 |
+
if not name or not email or not institution:
|
| 343 |
+
st.error("Por favor completa los campos obligatorios (*)")
|
| 344 |
+
return
|
| 345 |
+
|
| 346 |
+
if not is_institutional_email(email):
|
| 347 |
+
st.error("Por favor usa un correo institucional (no gmail, hotmail, etc.)")
|
| 348 |
+
return
|
| 349 |
+
|
| 350 |
+
# Rol por defecto como estudiante
|
| 351 |
+
desired_role = landing_t['student']
|
| 352 |
+
current_role = landing_t['student'] # Asumimos que son estudiantes
|
| 353 |
+
|
| 354 |
+
# Enviar solicitud
|
| 355 |
+
# Asegurar que todos los parámetros requeridos estén presentes
|
| 356 |
+
success = store_application_request(
|
| 357 |
+
name=name,
|
| 358 |
+
lastname="", # Apellido vacío
|
| 359 |
+
email=email,
|
| 360 |
+
institution=institution,
|
| 361 |
+
current_role=landing_t['student'], # Rol actual: estudiante
|
| 362 |
+
desired_role=landing_t['student'], # Rol deseado: estudiante
|
| 363 |
+
reason=reason if reason else "Solicitud de acceso simplificada"
|
| 364 |
+
)
|
| 365 |
+
if success:
|
| 366 |
+
st.success("✅ ¡Tu solicitud ha sido enviada! Recibirás un correo con instrucciones.")
|
| 367 |
+
logger.info(f"Solicitud almacenada exitosamente para {email}")
|
| 368 |
+
|
| 369 |
+
# Opcional: Limpiar formulario
|
| 370 |
+
st.rerun()
|
| 371 |
else:
|
| 372 |
+
st.error("❌ Hubo un error al enviar tu solicitud. Por favor, inténtalo de nuevo.")
|
| 373 |
+
logger.error(f"Error al almacenar solicitud para {email}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
|
| 375 |
#############################################################
|
| 376 |
#############################################################
|