printedparts stage 2: models, real 0001 baseline, tables live
Some checks failed
CI / backend (push) Successful in 1m39s
CI / naming (push) Successful in 2s
CI / frontend (push) Successful in 8s
CI / migrations-mysql (push) Failing after 8s

PrintedItem (catalog: code, name, image, cached quantityonhand,
per-item threshold, bin) and PrintedItemTransaction (the ledger:
signed quantity change attributed to a badge-resolved employee).
Both registered in PLUGIN_TABLE_OWNERS; 0001 is a post-cutover real
baseline. The migration-guard test learns the new expected head.
Routes are a placeholder ping until the next stage - the scaffold's
list route imported the deleted scaffold model, which surfaces as an
empty 'Migration error' because the alembic env imports the models
package.
This commit is contained in:
cproudlock
2026-07-16 16:57:21 -04:00
parent 8dd1fadeca
commit f5cfac33b4
10 changed files with 222 additions and 74 deletions

View File

@@ -1,45 +1,18 @@
"""Printedparts plugin API routes."""
"""Printedparts plugin API routes.
from flask import Blueprint, request
from flask_jwt_extended import jwt_required
Stage 2 placeholder: the blueprint must import cleanly for plugin discovery
and migrations (the alembic env imports the models package, which pulls in
plugin.py and this module). Real endpoints land in the next stage.
"""
from shopdb.api import (
success_response,
error_response,
paginated_response,
ErrorCodes,
get_pagination_params,
paginate_query,
)
from ..models import Printedparts
from flask import Blueprint
from shopdb.api import success_response
printedparts_bp = Blueprint('printedparts', __name__)
@printedparts_bp.route('', methods=['GET'])
@jwt_required(optional=True)
def list_printedparts():
"""List printedparts assets, paginated."""
page, per_page = get_pagination_params(request)
query = Printedparts.query
items, total = paginate_query(query, page, per_page)
data = [item.to_dict() for item in items]
return paginated_response(data, page, per_page, total)
@printedparts_bp.route('/<int:assetid>', methods=['GET'])
@jwt_required(optional=True)
def get_printedparts(assetid: int):
"""Get a single printedparts by assetid."""
item = Printedparts.query.get(assetid)
if not item:
return error_response(
ErrorCodes.NOT_FOUND,
f'Printedparts with assetid {assetid} not found',
http_code=404,
)
return success_response(item.to_dict())
@printedparts_bp.route('/ping', methods=['GET'])
def ping():
"""Liveness probe for the lab: proves the blueprint is registered."""
return success_response({'plugin': 'printedparts', 'status': 'ok'})