Adding on_website and preferred part indicators

This commit is contained in:
Ian Roddis committed 2026-09-21 14:01:23 -03:00
1 parent 13b64a2d17
commit 4fd2bb1b58
13 files changed
+331 -6

No files matched your search

+25 -3
View File
@@ -1674,6 +1674,7 @@ async def _default_augmented_parts_table_ctx(db: AsyncSession) -> dict:
"sort": "description",
"dir": "asc",
"include_archived": False,
"on_website": False,
}
@@ -1683,23 +1684,30 @@ async def augmented_parts_page(
sort: str = "description",
dir: str = "asc",
include_archived: bool = False,
on_website: bool = False,
db: AsyncSession = Depends(get_db),
user: User = Depends(web_require("augmented_parts:read")),
):
ctx = await _augmented_part_form_ctx(db)
total = await augmented_part_crud.count_filtered(
db, include_archived=include_archived
db, include_archived=include_archived, on_website=on_website
)
ctx["augmented_parts"] = await augmented_part_crud.list_filtered(
db,
sort=sort,
direction=dir,
include_archived=include_archived,
on_website=on_website,
limit=_PAGE_SIZE,
)
ctx["pagination"] = _paginate(
"/admin/augmented-parts/filter",
{"sort": sort, "dir": dir, "include_archived": include_archived},
{
"sort": sort,
"dir": dir,
"include_archived": include_archived,
"on_website": on_website,
},
1,
_PAGE_SIZE,
total,
@@ -1707,7 +1715,7 @@ async def augmented_parts_page(
)
ctx["sort_headers"] = _sort_headers(
"/admin/augmented-parts/filter",
{"include_archived": include_archived},
{"include_archived": include_archived, "on_website": on_website},
_AUGMENTED_PARTS_SORT_COLUMNS,
sort,
dir,
@@ -1716,6 +1724,7 @@ async def augmented_parts_page(
ctx["sort"] = sort
ctx["dir"] = dir
ctx["include_archived"] = include_archived
ctx["on_website"] = on_website
ctx["user"] = user
return templates.TemplateResponse(request, "admin/augmented_parts.html", ctx)
@@ -1730,6 +1739,8 @@ async def create_augmented_part(
scope_model_id: str = Form(""),
part_type_id: int = Form(...),
sub_part_type_id: str = Form(""),
on_website: bool = Form(False),
preferred_part: bool = Form(False),
db: AsyncSession = Depends(get_db),
actor: User = Depends(web_require("augmented_parts:write")),
):
@@ -1745,6 +1756,8 @@ async def create_augmented_part(
scope_model_id=int(scope_model_id) if scope_model_id else None,
part_type_id=part_type_id,
sub_part_type_id=int(sub_part_type_id) if sub_part_type_id else None,
on_website=on_website,
preferred_part=preferred_part,
)
await audit_crud.log(
db,
@@ -1874,6 +1887,7 @@ async def filter_augmented_parts(
part_type_id: str = "",
sub_part_type_id: str = "",
include_archived: bool = False,
on_website: bool = False,
sort: str = "description",
dir: str = "asc",
page: int = 1,
@@ -1895,6 +1909,7 @@ async def filter_augmented_parts(
part_type_id=part_type_id_int,
sub_part_type_id=sub_part_type_id_int,
include_archived=include_archived,
on_website=on_website,
)
filter_params = {
"description": description,
@@ -1904,6 +1919,7 @@ async def filter_augmented_parts(
"part_type_id": part_type_id,
"sub_part_type_id": sub_part_type_id,
"include_archived": include_archived,
"on_website": on_website,
}
pagination = _paginate(
"/admin/augmented-parts/filter",
@@ -1922,6 +1938,7 @@ async def filter_augmented_parts(
part_type_id=part_type_id_int,
sub_part_type_id=sub_part_type_id_int,
include_archived=include_archived,
on_website=on_website,
sort=sort,
direction=dir,
skip=pagination["skip"],
@@ -1945,6 +1962,7 @@ async def filter_augmented_parts(
"sort": sort,
"dir": dir,
"include_archived": include_archived,
"on_website": on_website,
},
)
@@ -2188,6 +2206,8 @@ async def update_augmented_part(
scope_model_id: str = Form(""),
part_type_id: int = Form(...),
sub_part_type_id: str = Form(""),
on_website: bool = Form(False),
preferred_part: bool = Form(False),
db: AsyncSession = Depends(get_db),
actor: User = Depends(web_require("augmented_parts:write")),
):
@@ -2207,6 +2227,8 @@ async def update_augmented_part(
"scope_model_id": int(scope_model_id) if scope_model_id else None,
"part_type_id": part_type_id,
"sub_part_type_id": int(sub_part_type_id) if sub_part_type_id else None,
"on_website": on_website,
"preferred_part": preferred_part,
}
await augmented_part_crud.update(db, ap, changes)
await audit_crud.log(