feat(signage): new widgets (shape, scrolling text, countdown, opening hours, Wi-Fi, contact details); the venue's opening hours on the server, edited on the Schedule page

Shapes: rectangle, circle, triangle, polygon, star or own corners, fill or gradient,
border. Countdown: to a time every day or a date, from now / a span before / a set
time, in venue time (the slide shows what is left right now). Opening hours, Wi-Fi
(with a join-the-network code) and contact details read the venue's identity and
opening hours (GET/PUT /api/identity/hours; Schedule -> Opening hours, shaded on its
timeline); the editor warns with a link when they're missing. Plan 6R.15, F-112.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 13:24:54 +02:00
co-authored by Claude Opus 5.5
parent 2a38602d45
commit f26e51273c
22 changed files with 1002 additions and 46 deletions
+39 -4
View File
@@ -82,7 +82,10 @@ class Background(_Strict):
fit: Literal["cover", "contain"] = "cover"
WidgetKind = Literal["logo", "name", "date", "clock", "message", "qr", "weather", "text", "menu", "stack"]
WidgetKind = Literal["logo", "name", "date", "clock", "message", "qr", "weather", "text", "menu", "stack",
"shape", "ticker", "countdown", "hours", "wifi", "contact"] # 6R.15
WHEN = r"^(\d{4}-\d{2}-\d{2}T)?([01]\d|2[0-3]):[0-5]\d$" # a countdown's moment: "HH:MM" (every day) or "YYYY-MM-DDTHH:MM"
ContactKey = Literal["phone", "phone2", "email", "address", "website", "google", "facebook", "instagram", "tiktok", "tripadvisor", "whatsapp", "viber"]
Position = Literal["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right", "top-bar", "bottom-bar", "custom"]
@@ -251,7 +254,7 @@ class Widget(_Strict):
box: Optional[Box] = None # position "custom"
align: Literal["auto", "left", "center", "right"] = "auto" # inside its place; auto: by its corner / box
media_id: Optional[int] = None # logo: a picture
text: Optional[str] = Field(default=None, max_length=200) # message: this text instead of the venue's
text: Optional[str] = Field(default=None, max_length=500) # message: this text instead of the venue's; text, ticker, a countdown's / hours' title
date_style: Literal["short", "long"] = "long"
clock_seconds: bool = False
qr_target: Literal["ordering", "menu", "custom"] = "ordering"
@@ -274,6 +277,37 @@ class Widget(_Strict):
qr_background: Optional[str] = Field(default=None, pattern=HEX) # around them (default white)
direction: Literal["row", "column"] = "row" # stack: side by side / one over the other
cells: List[Cell] = Field(default_factory=list, max_length=6)
# a shape (6R.15): in its box; a fill (flat, or a gradient to fill_to at fill_angle), a border
shape: Literal["rectangle", "circle", "triangle", "polygon", "star", "custom"] = "rectangle"
shape_sides: int = Field(default=6, ge=3, le=12) # polygon: its sides; star: its points
shape_inner: int = Field(default=45, ge=15, le=90) # star: its inner corners, % of the outer
shape_points: Optional[str] = Field(default=None, max_length=600) # custom: "x,y x,y …" in % of its box
fill: Optional[str] = Field(default=None, pattern=HEX)
fill_to: Optional[str] = Field(default=None, pattern=HEX) # None: one colour
fill_angle: int = Field(default=180, ge=0, le=359)
stroke: Optional[str] = Field(default=None, pattern=HEX)
stroke_width: int = Field(default=0, ge=0, le=20) # steps of ½ % of the shape's shorter side
radius: int = Field(default=0, ge=0, le=50) # rectangle: rounded corners, % of its shorter side
# scrolling text
ticker_speed: int = Field(default=4, ge=1, le=10)
ticker_direction: Literal["left", "right"] = "left"
# a countdown: to a time every day or a date and time (venue time); it counts from now, from a span
# before, or from a time; before that it shows the whole span or nothing; at the end a text or nothing
countdown_to: Optional[str] = Field(default=None, pattern=WHEN)
countdown_start: Literal["now", "before", "at"] = "now"
countdown_before: int = Field(default=120, ge=1, le=10080) # minutes
countdown_at: Optional[str] = Field(default=None, pattern=WHEN)
countdown_waiting: Literal["full", "hide"] = "full"
countdown_done: Optional[str] = Field(default=None, max_length=80)
countdown_done_hide: bool = False
# the opening hours (from the Schedule page): the week, or today only; days with the same hours on one line
hours_style: Literal["week", "today"] = "week"
hours_group: bool = True
# Wi-Fi (from the identity): its code to join, the password written out
wifi_qr: bool = True
wifi_password: bool = True
# contact details (from the identity): which, in this order
contact_fields: List[ContactKey] = Field(default_factory=lambda: ["phone", "website", "instagram"], max_length=12)
@model_validator(mode="after")
def _place(self):
@@ -1491,12 +1525,13 @@ def _venue(db) -> dict:
it: no internet, no place, too old) and its badges (owner review 5); its identity (6R.14: slogan,
colours, logos, Wi-Fi, contact) and time zone."""
from core.timeutil import venue_tz
from routers.identity import identity_out
from routers.identity import hours_out, identity_out
from services import signage_badges, weather
ident = identity_out(db)
ident.pop("name", None)
return {"name": _setting(db, "venue.name") or None, "message": _setting(db, MESSAGE) or None,
"weather": weather.current(db), "badges": signage_badges.load(db), "identity": ident, "timezone": venue_tz().key}
"weather": weather.current(db), "badges": signage_badges.load(db), "identity": ident, "timezone": venue_tz().key,
"hours": hours_out(db)}
class SlidePreviewBody(BaseModel):