feat: printing problems shown and handled; printing set-up on v2 (platform-v2 step 6.10)
- a ticket that doesn't print is a problem for whoever sent it and the managers: GET /api/print-problems (the order, table, dishes, printer, since when, tries, last error, who sent it) and three ways out: print again, send to another printer, handled (services/print_problems.py; print_jobs.resolved_by / redirected_to, Alembic 0036); live event print.problems from the print paths - phone: the red printer button opens the problems sheet, the table page warns (usePrintProblems replaces the 8 s poll); counter POS: a red button under the modes with the shared panel (@xenia/ordering PrintProblemsPanel + pure rules); manager: a card on the overview (top), the Tables page and the order page - manager: Settings -> Printing (printers with reachability, test print, network scan; ticket layout + test ticket, beep, fonts with previews, dot leader, dividers) and Management -> Prep zones (cards + zone dialog with the ticket language, printers, copies, sorting, category order, kitchen screen) rebuilt in src/pages/printing; v1 PrintFontsTab, PrepZonesConfigPage, PendingPrints and /api/orders/pending-prints removed - access: printer add/edit/delete/scan need core.settings.manage, prep zone changes catalog.menu.manage (were any dashboard user) - tests: test_print_problems.py, @xenia/ordering printProblems, manager printing.test.mjs, e2e print_problems.mjs (done-when) + manager.mjs printing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from core.access.deps import public
|
||||
from core.access.deps import public, require
|
||||
from core.access.queries import holders_filter
|
||||
from core.access.deps import require
|
||||
import asyncio
|
||||
import ipaddress
|
||||
import json
|
||||
@@ -206,8 +205,12 @@ def list_printers(db: Session = Depends(get_db), user: User = Depends(require_ma
|
||||
return db.query(Printer).all()
|
||||
|
||||
|
||||
# 6.10: adding, changing, removing and finding printers is venue set-up
|
||||
_SETTINGS = require("core.settings.manage")
|
||||
|
||||
|
||||
@router.post("/printers", response_model=PrinterOut)
|
||||
def create_printer(body: PrinterCreate, db: Session = Depends(get_db), user: User = Depends(require_manager)):
|
||||
def create_printer(body: PrinterCreate, db: Session = Depends(get_db), user: User = Depends(_SETTINGS)):
|
||||
printer = Printer(**body.model_dump())
|
||||
db.add(printer)
|
||||
db.commit()
|
||||
@@ -243,7 +246,7 @@ def test_beep(printer_id: int, n1: int = 2, n2: int = 2, n3: int = 1, db: Sessio
|
||||
|
||||
|
||||
@router.put("/printers/{printer_id}", response_model=PrinterOut)
|
||||
def update_printer(printer_id: int, body: PrinterUpdate, db: Session = Depends(get_db), user: User = Depends(require_manager)):
|
||||
def update_printer(printer_id: int, body: PrinterUpdate, db: Session = Depends(get_db), user: User = Depends(_SETTINGS)):
|
||||
printer = db.query(Printer).filter(Printer.id == printer_id).first()
|
||||
if not printer:
|
||||
raise XeniaError("printer.not_found")
|
||||
@@ -255,7 +258,7 @@ def update_printer(printer_id: int, body: PrinterUpdate, db: Session = Depends(g
|
||||
|
||||
|
||||
@router.delete("/printers/{printer_id}")
|
||||
def delete_printer(printer_id: int, db: Session = Depends(get_db), user: User = Depends(require_manager)):
|
||||
def delete_printer(printer_id: int, db: Session = Depends(get_db), user: User = Depends(_SETTINGS)):
|
||||
printer = db.query(Printer).filter(Printer.id == printer_id).first()
|
||||
if not printer:
|
||||
raise XeniaError("printer.not_found")
|
||||
@@ -337,7 +340,7 @@ async def _scan_subnet_sse(subnet: str, port: int, token: str):
|
||||
async def scan_printers(
|
||||
subnet: str = Query(default=""),
|
||||
port: int = Query(default=9100),
|
||||
user: User = Depends(require_manager),
|
||||
user: User = Depends(_SETTINGS),
|
||||
):
|
||||
"""SSE endpoint: scan a subnet for devices responding on the given port."""
|
||||
# Fall back to auto-detected subnet if none provided
|
||||
@@ -356,7 +359,7 @@ async def scan_printers(
|
||||
|
||||
|
||||
@router.get("/printers/scan-hints")
|
||||
def scan_hints(user: User = Depends(require_manager)):
|
||||
def scan_hints(user: User = Depends(_SETTINGS)):
|
||||
"""Return auto-detected local subnets to suggest in the scan UI."""
|
||||
return {"subnets": _detect_local_subnets()}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user