AIdeaText commited on
Commit
251925a
verified
1 Parent(s): 9f00dbb

Update modules/ui/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui/ui.py +39 -45
modules/ui/ui.py CHANGED
@@ -131,11 +131,11 @@ def login_register_page(lang_code, t):
131
 
132
  #############################################################
133
  #############################################################
134
- def login_form(lang_code, t):
135
  with st.form("login_form"):
136
- username = st.text_input(t.get("email", "Correo electr贸nico"))
137
- password = st.text_input(t.get("password", "Contrase帽a"), type="password")
138
- submit_button = st.form_submit_button(t.get("login", "Iniciar Sesi贸n"))
139
 
140
  if submit_button:
141
  success, role = authenticate_user(username, password)
@@ -150,44 +150,43 @@ def login_form(lang_code, t):
150
  logger.info(f"Usuario autenticado: {username}, Rol: {role}")
151
  st.rerun()
152
  else:
153
- st.error(t.get("invalid_credentials", "Credenciales incorrectas"))
154
 
155
 
156
  #############################################################
157
  #############################################################
158
- def register_form(lang_code, t):
159
- # st.header(t.get("request_trial", "Solicitar prueba de la aplicaci贸n"))
160
- name = st.text_input(t.get("name", "Nombre"))
161
- lastname = st.text_input(t.get("lastname", "Apellidos"))
162
- institution = st.text_input(t.get("institution", "Instituci贸n"))
163
- current_role = st.selectbox(t.get("current_role", "Rol en la instituci贸n donde labora"),
164
- [t.get("professor", "Profesor"), t.get("student", "Estudiante"), t.get("administrative", "Administrativo")])
165
 
166
  # Definimos el rol por defecto como estudiante
167
- desired_role = t.get("student", "Estudiante")
168
 
169
- email = st.text_input(t.get("institutional_email", "Correo electr贸nico de su instituci贸n"))
170
- reason = st.text_area(t.get("interest_reason", "驴Por qu茅 est谩s interesado en probar AIdeaText?"))
171
 
172
- if st.button(t.get("submit_application", "Enviar solicitud")):
173
- logger.info(f"Attempting to submit application for {email}")
174
- logger.debug(f"Form data: name={name}, lastname={lastname}, email={email}, institution={institution}, current_role={current_role}, desired_role={desired_role}, reason={reason}")
175
 
176
  if not name or not lastname or not email or not institution or not reason:
177
- logger.warning("Incomplete form submission")
178
- st.error(t.get("complete_all_fields", "Por favor, completa todos los campos."))
179
  elif not is_institutional_email(email):
180
- logger.warning(f"Non-institutional email used: {email}")
181
- st.error(t.get("use_institutional_email", "Por favor, utiliza un correo electr贸nico institucional."))
182
  else:
183
- logger.info(f"Attempting to store application for {email}")
184
  success = store_application_request(name, lastname, email, institution, current_role, desired_role, reason)
185
  if success:
186
- st.success(t.get("application_sent", "Tu solicitud ha sido enviada. Te contactaremos pronto."))
187
- logger.info(f"Application request stored successfully for {email}")
188
  else:
189
- st.error(t.get("application_error", "Hubo un problema al enviar tu solicitud. Por favor, intenta de nuevo m谩s tarde."))
190
- logger.error(f"Failed to store application request for {email}")
191
 
192
 
193
  #############################################################
@@ -199,17 +198,17 @@ def is_institutional_email(email):
199
 
200
  #############################################################
201
  #############################################################
202
- def display_videos_and_info(lang_code, t):
203
  # Crear tabs para cada secci贸n
204
  tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
205
- "Casos de uso",
206
- "Videos de presentaciones",
207
- "Ponencias acad茅micas",
208
- "Fotos de eventos",
209
- "Control de versiones"
210
  ])
211
 
212
- # Tab de Casos de uso
213
  with tab_use_case:
214
  use_case_videos = {
215
  "English - Radar use chart": "https://youtu.be/fFbbtlIewgs",
@@ -223,7 +222,7 @@ def display_videos_and_info(lang_code, t):
223
  "Espa帽ol - Uso del bot para buscar respuestas" : "https://www.youtube.com/watch?v=GFKDS0K2s7E"
224
  }
225
 
226
- selected_title = st.selectbox("Selecciona un caso de uso en espa帽ol o en ingl茅s:", list(use_case_videos.keys()))
227
  if selected_title in use_case_videos:
228
  try:
229
  st_player(use_case_videos[selected_title])
@@ -242,7 +241,7 @@ def display_videos_and_info(lang_code, t):
242
  "Demo de la versi贸n de escritorio.": "https://www.youtube.com/watch?v=nP6eXbog-ZY"
243
  }
244
 
245
- selected_title = st.selectbox("Selecciona una conferencia:", list(videos.keys()))
246
  if selected_title in videos:
247
  try:
248
  st_player(videos[selected_title])
@@ -332,16 +331,11 @@ def display_videos_and_info(lang_code, t):
332
  width=540) # Ajusta este valor seg煤n necesites
333
 
334
 
335
- # Tab de Novedades
336
  with tab_news:
337
- st.markdown("""
338
- ### Novedades de la versi贸n actual
339
- - Interfaz mejorada para una mejor experiencia de usuario
340
- - Optimizaci贸n del an谩lisis morfosint谩ctico
341
- - Soporte para m煤ltiples idiomas
342
- - Nuevo m贸dulo de an谩lisis del discurso
343
- - Sistema de chat integrado para soporte
344
- """)
345
 
346
  # Definici贸n de __all__ para especificar qu茅 se exporta
347
  __all__ = ['main', 'login_register_page', 'initialize_session_state']
 
131
 
132
  #############################################################
133
  #############################################################
134
+ def login_form(lang_code, landing_t):
135
  with st.form("login_form"):
136
+ username = st.text_input(landing_t['email'])
137
+ password = st.text_input(landing_t['password'], type="password")
138
+ submit_button = st.form_submit_button(landing_t['login_button'])
139
 
140
  if submit_button:
141
  success, role = authenticate_user(username, password)
 
150
  logger.info(f"Usuario autenticado: {username}, Rol: {role}")
151
  st.rerun()
152
  else:
153
+ st.error(landing_t['invalid_credentials'])
154
 
155
 
156
  #############################################################
157
  #############################################################
158
+ def register_form(lang_code, landing_t):
159
+ name = st.text_input(landing_t['name'])
160
+ lastname = st.text_input(landing_t['lastname'])
161
+ institution = st.text_input(landing_t['institution'])
162
+ current_role = st.selectbox(landing_t['current_role'],
163
+ [landing_t['professor'], landing_t['student'], landing_t['administrative']])
 
164
 
165
  # Definimos el rol por defecto como estudiante
166
+ desired_role = landing_t['student']
167
 
168
+ email = st.text_input(landing_t['institutional_email'])
169
+ reason = st.text_area(landing_t['interest_reason'])
170
 
171
+ if st.button(landing_t['submit_application']):
172
+ logger.info(f"Intentando enviar solicitud para {email}")
173
+ logger.debug(f"Datos del formulario: name={name}, lastname={lastname}, email={email}, institution={institution}, current_role={current_role}, desired_role={desired_role}, reason={reason}")
174
 
175
  if not name or not lastname or not email or not institution or not reason:
176
+ logger.warning("Env铆o de formulario incompleto")
177
+ st.error(landing_t['complete_all_fields'])
178
  elif not is_institutional_email(email):
179
+ logger.warning(f"Email no institucional utilizado: {email}")
180
+ st.error(landing_t['use_institutional_email'])
181
  else:
182
+ logger.info(f"Intentando almacenar solicitud para {email}")
183
  success = store_application_request(name, lastname, email, institution, current_role, desired_role, reason)
184
  if success:
185
+ st.success(landing_t['application_sent'])
186
+ logger.info(f"Solicitud almacenada exitosamente para {email}")
187
  else:
188
+ st.error(landing_t['application_error'])
189
+ logger.error(f"Error al almacenar solicitud para {email}")
190
 
191
 
192
  #############################################################
 
198
 
199
  #############################################################
200
  #############################################################
201
+ def display_videos_and_info(lang_code, landing_t):
202
  # Crear tabs para cada secci贸n
203
  tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
204
+ landing_t['use_cases'],
205
+ landing_t['presentation_videos'],
206
+ landing_t['academic_presentations'],
207
+ landing_t['event_photos'],
208
+ landing_t['version_control']
209
  ])
210
 
211
+ # Tab de Casos de uso
212
  with tab_use_case:
213
  use_case_videos = {
214
  "English - Radar use chart": "https://youtu.be/fFbbtlIewgs",
 
222
  "Espa帽ol - Uso del bot para buscar respuestas" : "https://www.youtube.com/watch?v=GFKDS0K2s7E"
223
  }
224
 
225
+ selected_title = st.selectbox(landing_t['select_use_case'], list(use_case_videos.keys()))
226
  if selected_title in use_case_videos:
227
  try:
228
  st_player(use_case_videos[selected_title])
 
241
  "Demo de la versi贸n de escritorio.": "https://www.youtube.com/watch?v=nP6eXbog-ZY"
242
  }
243
 
244
+ selected_title = st.selectbox(landing_t['select_presentation'], list(videos.keys()))
245
  if selected_title in videos:
246
  try:
247
  st_player(videos[selected_title])
 
331
  width=540) # Ajusta este valor seg煤n necesites
332
 
333
 
334
+ # Tab de Novedades - Usar contenido traducido
335
  with tab_news:
336
+ st.markdown(f"### {landing_t['latest_version_title']}")
337
+ for update in landing_t['version_updates']:
338
+ st.markdown(f"- {update}")
 
 
 
 
 
339
 
340
  # Definici贸n de __all__ para especificar qu茅 se exporta
341
  __all__ = ['main', 'login_register_page', 'initialize_session_state']