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>
87 lines
2.5 KiB
Python
87 lines
2.5 KiB
Python
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class SiteCreate(BaseModel):
|
|
name: str
|
|
owner_name: str
|
|
contact_email: str
|
|
license_expires_at: datetime
|
|
preset: str | None = "Everything (v1 sites)" # plan preset to fill `modules`; None = nothing licensed
|
|
|
|
|
|
class SiteModulesUpdate(BaseModel):
|
|
"""The whole module map: {key: {limits?: {name: int|null}, exp?: ISO datetime}}."""
|
|
modules: dict
|
|
|
|
|
|
class SiteUpdate(BaseModel):
|
|
name: str | None = None
|
|
owner_name: str | None = None
|
|
contact_email: str | None = None
|
|
license_expires_at: datetime | None = None
|
|
waiter_domain: str | None = None
|
|
menu_mode: str | None = None
|
|
menu_display_name: str | None = None
|
|
menu_tagline_en: str | None = None
|
|
menu_tagline_gr: str | None = None
|
|
menu_blurb_en: str | None = None
|
|
menu_blurb_gr: str | None = None
|
|
menu_hours: str | None = None
|
|
|
|
|
|
class SiteOut(BaseModel):
|
|
id: int
|
|
site_id: str
|
|
name: str
|
|
owner_name: str
|
|
contact_email: str
|
|
is_active: bool
|
|
is_locked: bool
|
|
lock_reason: str | None
|
|
license_expires_at: datetime
|
|
created_at: datetime
|
|
modules: dict = {}
|
|
module_catalog: list | None = None
|
|
module_catalog_at: datetime | None = None
|
|
last_seen_at: datetime | None
|
|
last_seen_ip: str | None
|
|
last_seen_local_ip: str | None
|
|
waiter_domain: str | None
|
|
menu_mode: str
|
|
menu_display_name: str | None
|
|
menu_tagline_en: str | None
|
|
menu_tagline_gr: str | None
|
|
menu_blurb_en: str | None
|
|
menu_blurb_gr: str | None
|
|
menu_hours: str | None
|
|
menu_header_image_url: str | None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class SiteCreatedOut(SiteOut):
|
|
secret_key: str
|
|
|
|
|
|
class LockRequest(BaseModel):
|
|
reason: str
|
|
|
|
|
|
class HeartbeatRequest(BaseModel):
|
|
"""C-1 v2 (docs/reference/cloud-contract.md)."""
|
|
version: str
|
|
local_ip: str | None = None
|
|
# The modules this site's code knows (D-20): [{key, kind, name, depends, limits: [{key, ...}]}]
|
|
module_catalog: list[dict] = []
|
|
|
|
|
|
class HeartbeatResponse(BaseModel):
|
|
# Signed v2 license the site stores and enforces offline (services/license_token.py).
|
|
# Everything about licensing is inside it; there are no unsigned license fields.
|
|
license_token: str | None
|
|
latest_version: str | None = None
|
|
waiter_domain: str | None = None
|
|
site_numeric_id: int # cloud DB pk — needed by the Connect workers
|
|
apps_url: str | None = None # the customer apps' public address (S.7; table QR codes)
|