phase 10
All checks were successful
CI/CD Pipeline / VM Test - backend-integration (push) Successful in 7s
CI/CD Pipeline / VM Test - full-stack (push) Successful in 7s
CI/CD Pipeline / VM Test - performance (push) Successful in 7s
CI/CD Pipeline / VM Test - security (push) Successful in 7s
CI/CD Pipeline / Backend Linting (push) Successful in 2s
CI/CD Pipeline / Frontend Linting (push) Successful in 15s
CI/CD Pipeline / Nix Flake Check (push) Successful in 41s
CI/CD Pipeline / CI Summary (push) Successful in 1s
All checks were successful
CI/CD Pipeline / VM Test - backend-integration (push) Successful in 7s
CI/CD Pipeline / VM Test - full-stack (push) Successful in 7s
CI/CD Pipeline / VM Test - performance (push) Successful in 7s
CI/CD Pipeline / VM Test - security (push) Successful in 7s
CI/CD Pipeline / Backend Linting (push) Successful in 2s
CI/CD Pipeline / Frontend Linting (push) Successful in 15s
CI/CD Pipeline / Nix Flake Check (push) Successful in 41s
CI/CD Pipeline / CI Summary (push) Successful in 1s
This commit is contained in:
@@ -15,6 +15,8 @@ from app.images.schemas import (
|
||||
BoardImageCreate,
|
||||
BoardImageResponse,
|
||||
BoardImageUpdate,
|
||||
BulkImageUpdate,
|
||||
BulkUpdateResponse,
|
||||
ImageListResponse,
|
||||
ImageResponse,
|
||||
ImageUploadResponse,
|
||||
@@ -357,6 +359,83 @@ async def remove_image_from_board(
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Image not on this board")
|
||||
|
||||
|
||||
@router.patch("/boards/{board_id}/images/bulk", response_model=BulkUpdateResponse)
|
||||
async def bulk_update_board_images(
|
||||
board_id: UUID,
|
||||
data: BulkImageUpdate,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Bulk update multiple images on a board.
|
||||
|
||||
Applies the same changes to all specified images. Useful for multi-selection operations.
|
||||
"""
|
||||
# Verify board ownership
|
||||
from sqlalchemy import select
|
||||
|
||||
board_result = await db.execute(select(Board).where(Board.id == board_id))
|
||||
board = board_result.scalar_one_or_none()
|
||||
|
||||
if not board:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Board not found")
|
||||
|
||||
if board.user_id != current_user.id:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Access denied")
|
||||
|
||||
# Update each image
|
||||
repo = ImageRepository(db)
|
||||
updated_ids = []
|
||||
failed_count = 0
|
||||
|
||||
for image_id in data.image_ids:
|
||||
try:
|
||||
# Calculate new position if delta provided
|
||||
position = None
|
||||
if data.position_delta:
|
||||
# Get current position
|
||||
board_image = await repo.get_board_image(board_id, image_id)
|
||||
if board_image and board_image.position:
|
||||
current_pos = board_image.position
|
||||
position = {
|
||||
"x": current_pos.get("x", 0) + data.position_delta["dx"],
|
||||
"y": current_pos.get("y", 0) + data.position_delta["dy"],
|
||||
}
|
||||
|
||||
# Calculate new z-order if delta provided
|
||||
z_order = None
|
||||
if data.z_order_delta is not None:
|
||||
board_image = await repo.get_board_image(board_id, image_id)
|
||||
if board_image:
|
||||
z_order = board_image.z_order + data.z_order_delta
|
||||
|
||||
# Update the image
|
||||
updated = await repo.update_board_image(
|
||||
board_id=board_id,
|
||||
image_id=image_id,
|
||||
position=position,
|
||||
transformations=data.transformations,
|
||||
z_order=z_order,
|
||||
group_id=None, # Bulk operations don't change groups
|
||||
)
|
||||
|
||||
if updated:
|
||||
updated_ids.append(image_id)
|
||||
else:
|
||||
failed_count += 1
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error updating image {image_id}: {e}")
|
||||
failed_count += 1
|
||||
continue
|
||||
|
||||
return BulkUpdateResponse(
|
||||
updated_count=len(updated_ids),
|
||||
failed_count=failed_count,
|
||||
image_ids=updated_ids,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/boards/{board_id}/images", response_model=list[BoardImageResponse])
|
||||
async def get_board_images(
|
||||
board_id: UUID,
|
||||
|
||||
Reference in New Issue
Block a user