Ajuste de mensajes de notificaciones y resolucion de notificaciones duplicadas backend 1.0.40

This commit is contained in:
2025-11-25 23:19:16 -03:00
parent 4c8938a24e
commit 773a9336ef
2 changed files with 32 additions and 4 deletions

View File

@@ -1090,9 +1090,24 @@ def create_answer(
db.commit() db.commit()
db.refresh(existing_answer) db.refresh(existing_answer)
# Enviar notificación si la pregunta lo requiere # Enviar notificación si la pregunta lo requiere Y hay un valor real
if question.send_notification: print(f"\n=== DEBUG NOTIFICACIÓN (UPDATE) ===")
print(f"Pregunta ID: {question.id}")
print(f"Texto: {question.text}")
print(f"send_notification: {question.send_notification}")
print(f"answer_value: '{answer.answer_value}'")
print(f"Tiene valor: {bool(answer.answer_value)}")
print(f"===================================\n")
# Solo enviar si tiene valor real (no vacío ni None)
if question.send_notification and answer.answer_value:
print(f"✅ Enviando notificación para pregunta #{question.id}")
send_answer_notification(existing_answer, question, current_user, db) send_answer_notification(existing_answer, question, current_user, db)
else:
if not question.send_notification:
print(f"❌ NO se envía notificación (send_notification=False) para pregunta #{question.id}")
else:
print(f"⏭️ NO se envía notificación (respuesta vacía) para pregunta #{question.id}")
return existing_answer return existing_answer
else: else:
@@ -1108,9 +1123,17 @@ def create_answer(
db.commit() db.commit()
db.refresh(db_answer) db.refresh(db_answer)
# Enviar notificación si la pregunta lo requiere
if question.send_notification:
# Solo enviar si tiene valor real (no vacío ni None)
if question.send_notification and answer.answer_value:
print(f"✅ Enviando notificación para pregunta #{question.id}")
send_answer_notification(db_answer, question, current_user, db) send_answer_notification(db_answer, question, current_user, db)
else:
if not question.send_notification:
print(f"❌ NO se envía notificación (send_notification=False) para pregunta #{question.id}")
else:
print(f"⏭️ NO se envía notificación (respuesta vacía) para pregunta #{question.id}")
return db_answer return db_answer

View File

@@ -1401,6 +1401,11 @@ function QuestionsManagerModal({ checklist, onClose }) {
{question.allow_photos && ( {question.allow_photos && (
<span>📷 Máx {question.max_photos} fotos</span> <span>📷 Máx {question.max_photos} fotos</span>
)} )}
{question.send_notification && (
<span className="px-2 py-1 bg-yellow-100 text-yellow-800 rounded text-xs">
🔔 Notificación
</span>
)}
</div> </div>
</div> </div>
</div> </div>