Plan phase 3S, step S.7.
- services/qr.py: the snapshot's `qr` {ordering, tables: [{id, label, token_hash}]} (sha256
of each table's token; the cloud never holds the tokens). A table order (dine_in) needs
the venue's ordering on, the site's menu_mode "order" and a valid table token: otherwise
order.service_unavailable / 403 order.table_invalid (a forged, old or typed-in table is
refused). The order keeps the table's id and label (online_orders.table_id, migration 0006).
- Public menu: ?t=<token> → `table` {id, label} or `table_invalid`; `table_ordering`; `qr`
never leaves the cloud.
- Heartbeat returns `apps_url` (new setting PUBLIC_APPS_URL: where /menu/ and /order/ are
served) so sites can print table QR codes that open the right address.
- Menu app: the table from its QR code (kept for the visit), a "Table 5" banner, ordering
only at a real table (otherwise read-only, with a notice for an invalid code); checkout
without a typed table number; prices are the QR menu's (sales point qr_table — it showed
in-store prices since S.1 removed digital_price) and only products sold there; the
confirmation page for table orders (in the kitchen); the delivery/takeaway leftovers
removed (they have their own app since S.4); test ids for e2e.
- Tests: tests/test_qr.py (3); test_checkout's typed-table case moved there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
from pydantic_settings import BaseSettings
|
|
|
|
_HERE = Path(__file__).parent
|
|
|
|
if os.name == "nt":
|
|
_DB_DIR = Path(os.environ.get("LOCALAPPDATA", Path.home() / "AppData" / "Local")) / "xenia_cloud"
|
|
_DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
_DEFAULT_DB = _DB_DIR / "cloud.db"
|
|
else:
|
|
_DEFAULT_DB = _HERE / "cloud.db"
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
SECRET_KEY: str = "change-me-generate-a-long-random-string"
|
|
DATABASE_URL: str = f"sqlite:///{_DEFAULT_DB.as_posix()}"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60
|
|
ADMIN_USERNAME: str = "sysadmin"
|
|
ADMIN_PASSWORD: str = "changeme"
|
|
LATEST_VERSION: str = "0.0.0"
|
|
# Ed25519 private key (base64, raw 32 bytes) that signs sites' license tokens.
|
|
# Generated once; the matching public key is built into client-services
|
|
# (local_backend/services/license.py). Keep secret, back up.
|
|
LICENSE_SIGNING_KEY: str = ""
|
|
# Manager JWT (separate secret from admin JWT)
|
|
MANAGER_JWT_SECRET: str = "change-me-manager-secret"
|
|
MANAGER_JWT_EXPIRE_HOURS: int = 72
|
|
# Where customers open the apps (connect_frontend: /menu/, /order/), e.g. https://menu.example.com.
|
|
# Sent to sites with the heartbeat so they can print table QR codes and show their ordering
|
|
# link (phase 3S, S.7). Empty = the sites use their CLOUD_URL.
|
|
PUBLIC_APPS_URL: str = ""
|
|
|
|
model_config = {"env_file": str(_HERE / ".env")}
|
|
|
|
|
|
settings = Settings()
|