feat: restringe soloAdmin (Bucefalo CRM) a agentes, default WhatsApp+fallbackEmail y archivado reversible

This commit is contained in:
urieljareth
2026-11-25 08:54:28 -06:00
parent 0d4f19f35d
commit 670265a390
31 changed files with 672 additions and 78 deletions
+4 -1
View File
@@ -23,8 +23,11 @@ async def list_clientes(
auth: dict = Depends(require_scope("clientes:leer")),
pagination: PaginationParams = Depends(PaginationParams),
q: str | None = Query(None, description="Search by nombre, empresa, or email"),
incluirArchivados: bool = Query(False, description="Solo personal humano"),
):
where_clauses: list[str] = []
if auth.get("auth_type") == "agent" or not incluirArchivados:
where_clauses.append("archivado = false")
params: list = []
idx = 1
@@ -116,7 +119,7 @@ async def get_cliente(
raise HTTPException(status_code=404, detail="Cliente no encontrado")
cotizaciones = await db.fetch(
'SELECT * FROM "Cotizacion" WHERE "clienteId" = $1 '
'SELECT * FROM "Cotizacion" WHERE "clienteId" = $1 AND archivado = false '
'ORDER BY "createdAt" DESC LIMIT 10',
cliente_id,
)