AIdeaText commited on
Commit
399e3a0
verified
1 Parent(s): 74be285

Update modules/database/sql_db.py

Browse files
Files changed (1) hide show
  1. modules/database/sql_db.py +14 -3
modules/database/sql_db.py CHANGED
@@ -267,8 +267,15 @@ def delete_student_user(username):
267
  return False
268
 
269
  def store_application_request(name, lastname, email, institution, current_role, desired_role, reason):
270
- _, application_requests_container, _ = get_container("application_request")
271
  try:
 
 
 
 
 
 
 
272
  application_request = {
273
  "id": str(uuid.uuid4()),
274
  "name": name,
@@ -278,11 +285,15 @@ def store_application_request(name, lastname, email, institution, current_role,
278
  "current_role": current_role,
279
  "desired_role": desired_role,
280
  "reason": reason,
281
- "requestDate": datetime.utcnow().isoformat()
 
282
  }
283
- application_requests_container.create_item(body=application_request)
 
 
284
  logger.info(f"Solicitud de aplicaci贸n almacenada para el email: {email}")
285
  return True
 
286
  except Exception as e:
287
  logger.error(f"Error al almacenar la solicitud de aplicaci贸n: {str(e)}")
288
  return False
 
267
  return False
268
 
269
  def store_application_request(name, lastname, email, institution, current_role, desired_role, reason):
270
+ """Almacena una solicitud de aplicaci贸n"""
271
  try:
272
+ # Obtener el contenedor - sin desempaquetado
273
+ container = get_container("application_requests")
274
+ if not container:
275
+ logger.error("No se pudo obtener el contenedor de solicitudes")
276
+ return False
277
+
278
+ # Crear el documento con la solicitud
279
  application_request = {
280
  "id": str(uuid.uuid4()),
281
  "name": name,
 
285
  "current_role": current_role,
286
  "desired_role": desired_role,
287
  "reason": reason,
288
+ "requestDate": datetime.utcnow().isoformat(),
289
+ "partitionKey": email # Necesario para CosmosDB
290
  }
291
+
292
+ # Crear el item en el contenedor
293
+ container.create_item(body=application_request)
294
  logger.info(f"Solicitud de aplicaci贸n almacenada para el email: {email}")
295
  return True
296
+
297
  except Exception as e:
298
  logger.error(f"Error al almacenar la solicitud de aplicaci贸n: {str(e)}")
299
  return False