Fix user delete flow 2
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
User management API routes
|
User management API routes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status, BackgroundTasks
|
from fastapi import APIRouter, Depends, HTTPException, status, BackgroundTasks, Path
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
import structlog
|
import structlog
|
||||||
@@ -123,8 +123,8 @@ async def update_current_user(
|
|||||||
|
|
||||||
@router.delete("/delete/{user_id}")
|
@router.delete("/delete/{user_id}")
|
||||||
async def delete_admin_user(
|
async def delete_admin_user(
|
||||||
user_id: str,
|
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
|
user_id: str = Path(..., description="User ID"),
|
||||||
current_user = Depends(get_current_user_dep),
|
current_user = Depends(get_current_user_dep),
|
||||||
_admin_check = Depends(require_admin_role),
|
_admin_check = Depends(require_admin_role),
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
@@ -237,7 +237,7 @@ async def execute_admin_user_deletion(
|
|||||||
|
|
||||||
@router.get("/delete/{user_id}/deletion-preview")
|
@router.get("/delete/{user_id}/deletion-preview")
|
||||||
async def preview_user_deletion(
|
async def preview_user_deletion(
|
||||||
user_id: str,
|
user_id: str = Path(..., description="User ID"),
|
||||||
current_user = Depends(get_current_user_dep),
|
current_user = Depends(get_current_user_dep),
|
||||||
_admin_check = Depends(require_admin_role),
|
_admin_check = Depends(require_admin_role),
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
|
|||||||
@@ -97,20 +97,6 @@ async def training_progress_websocket(
|
|||||||
setup_rabbitmq_consumer_for_job(job_id, tenant_id)
|
setup_rabbitmq_consumer_for_job(job_id, tenant_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
await asyncio.sleep(0.5)
|
|
||||||
|
|
||||||
# Send initial status
|
|
||||||
try:
|
|
||||||
initial_status = await get_current_job_status(job_id, tenant_id)
|
|
||||||
if initial_status:
|
|
||||||
await websocket.send_json({
|
|
||||||
"type": "initial_status",
|
|
||||||
"job_id": job_id,
|
|
||||||
"data": initial_status
|
|
||||||
})
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Failed to send initial status: {e}")
|
|
||||||
|
|
||||||
last_activity = asyncio.get_event_loop().time()
|
last_activity = asyncio.get_event_loop().time()
|
||||||
|
|
||||||
while not training_completed:
|
while not training_completed:
|
||||||
|
|||||||
@@ -845,7 +845,8 @@ log_step "6.1. Getting deletion preview for test user"
|
|||||||
|
|
||||||
# First, get a preview of what would be deleted
|
# First, get a preview of what would be deleted
|
||||||
DELETION_PREVIEW_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X GET "$API_BASE/api/v1/users/delete/$USER_ID/deletion-preview" \
|
DELETION_PREVIEW_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X GET "$API_BASE/api/v1/users/delete/$USER_ID/deletion-preview" \
|
||||||
-H "Authorization: Bearer $ACCESS_TOKEN")
|
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||||
|
-H "Content-Type: application/json")
|
||||||
|
|
||||||
# Extract HTTP code and response
|
# Extract HTTP code and response
|
||||||
HTTP_CODE=$(echo "$DELETION_PREVIEW_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
|
HTTP_CODE=$(echo "$DELETION_PREVIEW_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
|
||||||
|
|||||||
Reference in New Issue
Block a user