feat: the venue's identity in every app: its colour as the accent of the waiters' phones and every terminal screen, customer display looks on the identity, the signage logo widget falls back to the venue's logo

Settings -> Venue -> accent "The venue's identity" (venue.theme = identity): bootstrap
carries the identity's first colour and logos; @xenia/ui applyVenueTheme makes the
accent tokens (light and dark, readable foregrounds) from it. A display look's
"Colours and logo" can be the venue's identity. Plan 6R.20, F-117.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:30:14 +02:00
co-authored by Claude Opus 5.5
parent 0bd32d9171
commit 1b111c0e27
20 changed files with 229 additions and 28 deletions
+17
View File
@@ -38,6 +38,22 @@ router = APIRouter()
_optional_bearer = HTTPBearer(auto_error=False)
def _identity_brief(db) -> dict:
"""What every app needs of the venue's identity (6R.20): its first colour (the accent when
venue.theme is "identity"), the slogan and the logos' addresses. Public, like the venue's name."""
try:
from routers.identity import identity_out
ident = identity_out(db)
except Exception:
return {"colour": None, "slogan": None, "logo": None, "logo_light": None, "logo_dark": None, "icon": None}
logos = ident.get("logos") or {}
def card(k):
return (logos.get(k) or {}).get("card")
return {"colour": (ident.get("colours") or [{}])[0].get("colour"), "slogan": ident.get("slogan"),
"logo": card("main"), "logo_light": card("light"), "logo_dark": card("dark"), "icon": (logos.get("icon") or {}).get("thumb")}
def permission_keys_for(user) -> list[str]:
"""The keys a user holds (user_permissions; superadmin: every key)."""
from core.access.check import user_keys
@@ -113,6 +129,7 @@ def bootstrap(
"language": i18n.venue_language(),
"currency": _setting(db, "venue.currency", "EUR"),
"theme": _setting(db, "venue.theme", "amber") or "amber", # the accent colour (4.6, data-venue-theme)
"identity": _identity_brief(db), # 6R.20: its colour and logos for the apps
"business_day_rollover_hour": timeutil.rollover_hour(),
},
"modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective],
+1 -1
View File
@@ -35,7 +35,7 @@ MODULE = Module(
SettingDef('venue.name', '', 'Venue name shown on screens and tickets.', type='str'),
SettingDef('venue.opening_hours', '{}', 'Opening hours, Monday first (6R.15; JSON {days, note}; edited on the Schedule page, shown by signage).', type='json'),
SettingDef('venue.identity', '{}', "The venue's identity (6R.14): slogan, colours, logos, Wi-Fi, contact details (JSON; Settings > Identity, routers/identity.py).", type='json'),
SettingDef('venue.theme', 'amber', "Accent colour of the staff apps (the waiter's phones first, plan step 4.6): 'teal' | 'amber' | 'blue' | 'violet' | 'rose'", type='enum', choices=('teal', 'amber', 'blue', 'violet', 'rose')),
SettingDef('venue.theme', 'amber', "Accent colour of the staff apps (the waiter's phones first, plan step 4.6): 'teal' | 'amber' | 'blue' | 'violet' | 'rose', or 'identity' = the first colour of the venue's identity (6R.20: also the counter, KDS and tablets)", type='enum', choices=('teal', 'amber', 'blue', 'violet', 'rose', 'identity')),
SettingDef('venue.type', '', 'Kind of venue (restaurant, cafe, bar...), chosen in the setup wizard.', type='str'),
SettingDef('venue.currency', 'EUR', 'ISO 4217 currency of all prices.', type='str'),
),
+10 -1
View File
@@ -64,6 +64,7 @@ class IdleBody(BaseModel):
qr_url: Optional[str] = Field(default=None, max_length=300)
qr_caption: Optional[str] = Field(default=None, max_length=80)
theme: Literal["dark", "light"] = "dark"
brand: Literal["own", "identity"] = "own" # 6R.20: the venue's identity: its colour as the accent, its logo when the look has none
@field_validator("qr_url")
@classmethod
@@ -157,7 +158,15 @@ def idle_out(db, look: DisplayLook | None) -> dict:
cfg = config_of(look)
pics = _pictures(db, [cfg["logo"], cfg["image"], *cfg["slides"]])
url = lambda i, size: (media_store.image_of(pics[i]) or {}).get(size) if i in pics else None # noqa: E731
return {**cfg, "logo_url": url(cfg["logo"], "card"), "image_url": url(cfg["image"], "full"),
logo = url(cfg["logo"], "card")
accent = None
if cfg.get("brand") == "identity":
from core.modules.api import _identity_brief
ib = _identity_brief(db)
accent = ib["colour"]
# its own logo first; else the identity's (the one made for this background, else the main one)
logo = logo or (ib["logo_light"] if cfg.get("theme", "dark") == "dark" else ib["logo_dark"]) or ib["logo"]
return {**cfg, "logo_url": logo, "accent": accent, "image_url": url(cfg["image"], "full"),
"slide_urls": [u for u in (url(i, "full") for i in cfg["slides"]) if u],
"qr_link": _qr_link(cfg) if cfg["style"] == "qr" else None}
+10
View File
@@ -8,3 +8,13 @@ def test_venue_theme_reaches_bootstrap(client, make_user, login):
assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "blue"
r = client.put("/api/settings/venue.theme", headers=owner, json={"value": "neon"})
assert r.status_code in (400, 422)
def test_the_identity_as_the_staff_apps_colour(client, make_user, login):
"""6R.20: venue.theme "identity" = the first colour of the venue's identity; bootstrap carries it and the logos."""
owner = login(make_user(role="owner"))
assert client.get("/api/platform/bootstrap").json()["venue"]["identity"]["colour"] is None
client.put("/api/identity", headers=owner, json={"colours": [{"name": "Main", "colour": "#1E3A8A"}], "slogan": "Since 1987"})
assert client.put("/api/settings/venue.theme", headers=owner, json={"value": "identity"}).status_code == 200
v = client.get("/api/platform/bootstrap").json()["venue"]
assert v["theme"] == "identity" and v["identity"]["colour"] == "#1e3a8a" and v["identity"]["slogan"] == "Since 1987" and v["identity"]["logo"] is None