first commit

This commit is contained in:
2025-11-19 01:09:25 -03:00
parent e7a380f36e
commit be10a888fb
28 changed files with 2481 additions and 464 deletions

View File

@@ -1,22 +1,39 @@
"""
Script para agregar preguntas a un checklist basado en el formato del PDF
Ejecutar: docker cp add_questions.py checklist-backend:/app/ && docker-compose exec -T backend python /app/add_questions.py
Ejecutar: docker-compose exec -T backend python /app/add_questions.py
"""
from app.core.database import SessionLocal
from app.models import Checklist, Question
# ID del checklist al que quieres agregar preguntas
CHECKLIST_ID = 2 # Cambia este número según el ID de tu checklist
from app.models import Checklist, Question, User
db = SessionLocal()
# Verificar que el checklist existe
checklist = db.query(Checklist).filter(Checklist.id == CHECKLIST_ID).first()
if not checklist:
print(f"Checklist con ID {CHECKLIST_ID} no encontrado")
# Obtener el usuario admin
admin = db.query(User).filter(User.username == "admin").first()
if not admin:
print("Usuario admin no encontrado")
exit(1)
# Verificar si ya existe un checklist, si no, crearlo
checklist = db.query(Checklist).filter(Checklist.name == "Inspección Preventiva de Vehículos").first()
if not checklist:
print("📋 Creando checklist...")
checklist = Checklist(
name="Inspección Preventiva de Vehículos",
description="Checklist completo para inspección preventiva de vehículos",
ai_mode="off",
scoring_enabled=True,
created_by=admin.id
)
db.add(checklist)
db.commit()
db.refresh(checklist)
print(f"✅ Checklist creado con ID: {checklist.id}")
else:
print(f"✅ Usando checklist existente: {checklist.name} (ID: {checklist.id})")
CHECKLIST_ID = checklist.id
print(f"✅ Agregando preguntas al checklist: {checklist.name}")
# Definir todas las preguntas por sección