Adding post-import adjustments

This commit is contained in:
Ian Roddis committed 2026-07-02 13:12:09 -03:00
1 parent c320595423
commit 87019ff2af
6 files changed
+170 -3

No files matched your search

+45 -1
View File
@@ -1143,6 +1143,7 @@ async def augmented_parts_page(
ctx = await _augmented_part_form_ctx(db)
ctx["user"] = user
ctx["augmented_parts"] = await augmented_part_crud.list_all(db)
ctx["unlinked_parts"] = await augmented_part_crud.get_unlinked_imported_parts(db)
return templates.TemplateResponse(request, "admin/augmented_parts.html", ctx)
@@ -1208,17 +1209,60 @@ async def sync_augmented_parts(
except Exception as exc:
sync_result = None
sync_error = f"Sync failed: {exc}"
form_ctx = await _augmented_part_form_ctx(db)
return templates.TemplateResponse(
request,
"admin/_augmented_parts_table.html",
"admin/_augmented_parts_sections.html",
{
**form_ctx,
"augmented_parts": await augmented_part_crud.list_all(db),
"unlinked_parts": await augmented_part_crud.get_unlinked_imported_parts(db),
"sync_result": sync_result,
"sync_error": sync_error,
},
)
@router.post("/augmented-parts/unlinked", response_class=HTMLResponse)
async def sync_unlinked_part(
request: Request,
inventory_id: str = Form(...),
part_type_id: int = Form(...),
sub_part_type_id: str = Form(""),
db: AsyncSession = Depends(get_db),
actor: User = Depends(web_require("augmented_parts:write")),
):
try:
ap = await augmented_part_sync_service.sync_one(
db,
inventory_id=inventory_id,
part_type_id=part_type_id,
sub_part_type_id=int(sub_part_type_id) if sub_part_type_id else None,
)
await audit_crud.log(
db, actor=actor, action="create", resource_type="AugmentedPart",
resource_id=ap.id,
description=audit_crud.describe_create("AugmentedPart", ap.id, ap.description),
)
unlinked_sync_result = f"Created Augmented Part for '{ap.description}'."
unlinked_sync_error = None
except Exception as exc:
unlinked_sync_result = None
unlinked_sync_error = f"Sync failed: {exc}"
form_ctx = await _augmented_part_form_ctx(db)
return templates.TemplateResponse(
request,
"admin/_augmented_parts_sections.html",
{
**form_ctx,
"augmented_parts": await augmented_part_crud.list_all(db),
"unlinked_parts": await augmented_part_crud.get_unlinked_imported_parts(db),
"unlinked_sync_result": unlinked_sync_result,
"unlinked_sync_error": unlinked_sync_error,
},
)
@router.get("/augmented-parts/{augmented_part_id}/edit", response_class=HTMLResponse)
async def edit_augmented_part_row(
request: Request,