Files
shopdb-flask/shopdb/plugins/templates/api/routes.py.tmpl
Cam Proudlock a9d0dfff4a Initial import: shopdb-flask multi-site asset platform
Flask + Vue rewrite of the classic-ASP shopdb, built as a plugin
framework so sister GE Aerospace sites can adopt it. Product version
0.7.0-pre-0.8.0, plugin contract 0.11.0, 966 backend tests.

Key entry points:
- docs/INSTALL-WINDOWS-IIS.md - tested Windows + IIS install runbook
  (own-site and subpath deployment methods)
- docs/PILOT-DEPLOY.md - production pilot: stand up + import + verify
- docs/IMPORT-API.md - schema-agnostic legacy data import contract
- scripts/site_imports/wjf/ - West Jefferson reference import loader
- docs/adr/ - twelve accepted architecture decision records
2026-07-14 07:58:51 -04:00

46 lines
1.1 KiB
Cheetah

"""$Name plugin API routes."""
from flask import Blueprint, request
from flask_jwt_extended import jwt_required
from shopdb.api import (
success_response,
error_response,
paginated_response,
ErrorCodes,
get_pagination_params,
paginate_query,
)
from ..models import $Name
${name}_bp = Blueprint('$name', __name__)
@${name}_bp.route('', methods=['GET'])
@jwt_required(optional=True)
def list_${name}():
"""List $name assets, paginated."""
page, per_page = get_pagination_params(request)
query = ${Name}.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)
@${name}_bp.route('/<int:assetid>', methods=['GET'])
@jwt_required(optional=True)
def get_${name}(assetid: int):
"""Get a single $name by assetid."""
item = ${Name}.query.get(assetid)
if not item:
return error_response(
ErrorCodes.NOT_FOUND,
f'$Name with assetid {assetid} not found',
http_code=404,
)
return success_response(item.to_dict())