Adding sync with imported parts
This commit is contained in:
1 parent
00fb43c8ed
commit
c320595423
11 files changed
+300
-4
No files matched your search
@@ -9,8 +9,10 @@ from app.models.user import User
|
||||
from app.schemas.augmented_part import (
|
||||
AugmentedPartCreate,
|
||||
AugmentedPartRead,
|
||||
AugmentedPartSyncResult,
|
||||
AugmentedPartUpdate,
|
||||
)
|
||||
from app.services import augmented_part_sync
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -49,6 +51,23 @@ async def create_augmented_part(
|
||||
return ap
|
||||
|
||||
|
||||
@router.post("/sync", response_model=AugmentedPartSyncResult)
|
||||
async def sync_augmented_parts(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
actor: User = Depends(require_permission("augmented_parts:write")),
|
||||
):
|
||||
result = await augmented_part_sync.sync(db)
|
||||
await audit_crud.log(
|
||||
db, actor=actor, action="update", resource_type="AugmentedPart",
|
||||
resource_id=None,
|
||||
description=(
|
||||
f"Sync: {result.created} created, {result.deleted} deleted, "
|
||||
f"{result.skipped} skipped (no type match)"
|
||||
),
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/{augmented_part_id}", response_model=AugmentedPartRead)
|
||||
async def get_augmented_part(
|
||||
augmented_part_id: int,
|
||||
|
||||
Reference in new issue
Block a user