Nuevos cambios en el servidor

This commit is contained in:
2026-01-27 13:22:13 -07:00
parent 6215fc40a7
commit 7bb3d1a0ac
33 changed files with 8737 additions and 169 deletions

View File

@@ -85,6 +85,9 @@ async def update_tenant(
raise HTTPException(status_code=404, detail="Tenant not found")
update_data = tenant_in.model_dump(exclude_unset=True)
if "status" in update_data:
tenant.is_active = update_data.pop("status") == TenantStatus.active
for field, value in update_data.items():
setattr(tenant, field, value)
@@ -92,3 +95,18 @@ async def update_tenant(
await db.commit()
await db.refresh(tenant)
return tenant
@router.delete("/{tenant_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_tenant(
tenant_id: uuid.UUID,
db: AsyncSession = Depends(get_db),
current_user = Depends(deps.get_current_active_superuser)
):
"""Eliminar un cliente (tenant) por ID."""
tenant = await db.get(Tenant, tenant_id)
if not tenant:
raise HTTPException(status_code=404, detail="Tenant not found")
await db.delete(tenant)
await db.commit()
return {"message": "Tenant deleted successfully"}