feat(backend): signage menu boards: any products, the board's own order, live prices (platform-v2 step 5.4b)
- MenuContent: select all / whole categories (with sub-categories, live: new products join) / single products, exclusions; grouped by category or not, headings; the board's own category and product order; a sales point's prices or none; photos, descriptions, badges (new, chef, offer, popular, spicy, vegetarian, vegan); sold-out crossed out or hidden; columns, items per page, seconds per page, font, colours, size, background. - services/signage_menu.resolve: the products in that order with customer-facing names, prices from pos_cart.unit_prices (what the counter charges right now), availability, card-size photos. GET /api/signage/screen includes each menu slide's `menu`. - Every request that changes the menu (the online menu's paths) also sends signage.changed to the screens with a menu board (main.py, off the loop). - tests: test_signage_menu.py (6); 515 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,9 +106,24 @@ async def _menu_change_push(request, call_next):
|
||||
from services.cloud_sync import menu_changed, request_menu_push
|
||||
if menu_changed(request.method, request.url.path, response.status_code):
|
||||
request_menu_push()
|
||||
from starlette.concurrency import run_in_threadpool
|
||||
await run_in_threadpool(_signage_menu_changed)
|
||||
return response
|
||||
|
||||
|
||||
def _signage_menu_changed() -> None:
|
||||
"""The signage screens showing a menu board read it again (plan step 5.4b)."""
|
||||
try:
|
||||
from routers.signage import menu_changed as signage_menu_changed
|
||||
db = SessionLocal()
|
||||
try:
|
||||
signage_menu_changed(db)
|
||||
finally:
|
||||
db.close()
|
||||
except Exception as e: # never breaks the request that changed the menu
|
||||
logger.warning("signage: menu change not sent: %s", e)
|
||||
|
||||
|
||||
# Added last = outermost: the request id exists before any other middleware runs.
|
||||
app.add_middleware(RequestContextMiddleware)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user