Adding archived flag to augmented parts, fixing migrations so that creation from scratch is successful
This commit is contained in:
1 parent
740dfc97c7
commit
413e9e8381
27 files changed
+695
-126
No files matched your search
@@ -24,10 +24,13 @@ router = APIRouter()
|
||||
async def list_augmented_parts(
|
||||
skip: int = 0,
|
||||
limit: int = 100,
|
||||
include_archived: bool = False,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
_: User = Depends(require_permission("augmented_parts:read")),
|
||||
):
|
||||
return await augmented_part_crud.list_all(db, skip=skip, limit=limit)
|
||||
return await augmented_part_crud.list_all(
|
||||
db, skip=skip, limit=limit, include_archived=include_archived
|
||||
)
|
||||
|
||||
|
||||
@router.post("", response_model=AugmentedPartRead, status_code=status.HTTP_201_CREATED)
|
||||
@@ -72,7 +75,7 @@ async def sync_augmented_parts(
|
||||
resource_type="AugmentedPart",
|
||||
resource_id=None,
|
||||
description=(
|
||||
f"Sync: {result.created} created, {result.deleted} deleted, "
|
||||
f"Sync: {result.created} created, {result.archived} archived, "
|
||||
f"{result.skipped} skipped (no type match)"
|
||||
),
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ from app.schemas.imported_part import (
|
||||
ImportedPartRead,
|
||||
SyncResult,
|
||||
)
|
||||
from app.services import augmented_part_sync
|
||||
from app.services import odata as odata_service
|
||||
|
||||
router = APIRouter()
|
||||
@@ -128,7 +129,9 @@ async def delete_imported_part(
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Imported part not found"
|
||||
)
|
||||
await imported_part_crud.delete(db, part)
|
||||
archived = await augmented_part_sync.delete_imported_part_and_archive_orphans(
|
||||
db, part
|
||||
)
|
||||
await audit_crud.log(
|
||||
db,
|
||||
actor=actor,
|
||||
@@ -137,3 +140,15 @@ async def delete_imported_part(
|
||||
resource_id=None,
|
||||
description=audit_crud.describe_delete("ImportedPart", 0, inventory_id),
|
||||
)
|
||||
if archived:
|
||||
await audit_crud.log(
|
||||
db,
|
||||
actor=actor,
|
||||
action="update",
|
||||
resource_type="AugmentedPart",
|
||||
resource_id=None,
|
||||
description=(
|
||||
f"Archived {archived} augmented part(s) left with no remaining "
|
||||
f"imported parts after deleting {inventory_id!r}"
|
||||
),
|
||||
)
|
||||
Reference in new issue
Block a user