- build.py: _TEMPLATE_COMPONENTS rewritten around the vet sample (53 kinds —
per-resource slices, jobs, worked appointment_reminder family, tests);
seed tokens dropped from the manifest ('sample: vet' instead)
- registry.py: get_app_component(kind) no longer renames item/example seeds;
prompts and tool docs updated to 'copy a slice and adapt'
- templates/README.md, 01_build_recipe, 40_ui_admin, wiki/03 updated off the
old seed scheme; repo inventory/config now exclude vet (docs move under
standards; react/vet itself is deleted in a later phase)
- regenerated MCP bundle, vendored templates, and site output
91 lines
2.5 KiB
Python
91 lines
2.5 KiB
Python
"""# Summary
|
|
|
|
Parents route handlers — names must match openapi.yaml operationIds.
|
|
"""
|
|
from fastapi import Request, Response
|
|
|
|
from interfaces._common import delete_or_404, dump, paginate, read_or_404, svc
|
|
|
|
|
|
async def list_parents(request: Request, limit: int = 20, offset: int = 0) -> dict:
|
|
"""List parents (paginated). ``limit=0`` returns all remaining items.
|
|
|
|
Args:
|
|
request (Request): Incoming request.
|
|
limit (int): Page size. Defaults to 20.
|
|
offset (int): Items to skip. Defaults to 0.
|
|
|
|
Returns:
|
|
dict: ``{"total": int, "items": list[Parent]}``.
|
|
"""
|
|
docs = await svc(request, "parent").search({})
|
|
return paginate([dump(d) for d in docs], limit, offset)
|
|
|
|
|
|
async def create_parent(request: Request, body: dict, response: Response) -> dict:
|
|
"""Create a parent.
|
|
|
|
Args:
|
|
request (Request): Incoming request.
|
|
body (dict): Parent fields (``id`` ignored).
|
|
response (Response): Response object; set to 201 on success.
|
|
|
|
Returns:
|
|
dict: The created parent.
|
|
"""
|
|
response.status_code = 201
|
|
body.pop("id", None)
|
|
doc = await svc(request, "parent").create(body)
|
|
return dump(doc)
|
|
|
|
|
|
async def get_parent(request: Request, id: int) -> dict:
|
|
"""Fetch one parent by id.
|
|
|
|
Args:
|
|
request (Request): Incoming request.
|
|
id (int): Parent identifier.
|
|
|
|
Returns:
|
|
dict: The parent document.
|
|
|
|
Raises:
|
|
HTTPException: 404 when the parent does not exist.
|
|
"""
|
|
return dump(await read_or_404(svc(request, "parent"), id, "parent"))
|
|
|
|
|
|
async def update_parent(request: Request, id: int, body: dict) -> dict:
|
|
"""Replace a parent by id.
|
|
|
|
Args:
|
|
request (Request): Incoming request.
|
|
id (int): Parent identifier.
|
|
body (dict): Full replacement payload.
|
|
|
|
Returns:
|
|
dict: The updated parent.
|
|
|
|
Raises:
|
|
HTTPException: 404 when the parent does not exist.
|
|
"""
|
|
await read_or_404(svc(request, "parent"), id, "parent")
|
|
body.pop("id", None)
|
|
doc = await svc(request, "parent").update(id, body)
|
|
return dump(doc)
|
|
|
|
|
|
async def delete_parent(request: Request, id: int, response: Response) -> None:
|
|
"""Delete a parent by id.
|
|
|
|
Args:
|
|
request (Request): Incoming request.
|
|
id (int): Parent identifier.
|
|
response (Response): Response object; set to 204 on success.
|
|
|
|
Raises:
|
|
HTTPException: 404 when the parent does not exist.
|
|
"""
|
|
await delete_or_404(svc(request, "parent"), id, "parent")
|
|
response.status_code = 204
|