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
View File
@@ -45,3 +45,42 @@ def test_checked(client, owner_h):
assert err(client.put("/api/identity", headers=owner_h, json={"logos": {"main": 99999}})) == "media.not_found"
too_many = [{"name": f"c{i}", "colour": "#000000"} for i in range(13)]
assert client.put("/api/identity", headers=owner_h, json={"colours": too_many}).status_code == 422
def test_opening_hours(client, owner_h, screens, sent):
assert client.get("/api/identity/hours", headers=owner_h).json() == {"days": [[]] * 7, "note": None, "set": False}
days = [[{"from": "18:00", "to": "23:00"}, {"from": "12:00", "to": "15:00"}]] * 5 + [[{"from": "12:00", "to": "01:00"}], []]
sent.clear()
r = client.put("/api/identity/hours", headers=owner_h, json={"days": days, "note": " Closed on holidays "})
assert r.status_code == 200, r.text
j = r.json()
assert j["set"] is True and j["days"][0] == [{"from": "12:00", "to": "15:00"}, {"from": "18:00", "to": "23:00"}]
assert j["days"][6] == [] and j["note"] == "Closed on holidays"
assert ("signage.changed", sorted([screens[1]["id"], screens[2]["id"]])) in sent
assert client.get("/api/signage/screen", headers=screens[1]["h"]).json()["venue"]["hours"]["days"][5] == [{"from": "12:00", "to": "01:00"}]
assert client.put("/api/identity/hours", headers=owner_h, json={"days": [[]] * 6}).status_code == 422
assert client.put("/api/identity/hours", headers=owner_h, json={"days": [[{"from": "25:00", "to": "01:00"}]] + [[]] * 6}).status_code == 422
def test_new_widgets_are_typed(client, owner_h):
from tests.test_signage import playlist, slide
p = playlist(client, owner_h)
widgets = [
{"kind": "shape", "position": "custom", "box": {"x": 10, "y": 10, "w": 20, "h": 20}, "shape": "star", "shape_sides": 5, "fill": "#ff0000", "fill_to": "#0000ff"},
{"kind": "ticker", "position": "bottom-bar", "text": "Fresh fish today " * 10, "ticker_speed": 7},
{"kind": "countdown", "countdown_to": "17:00", "countdown_start": "before", "countdown_before": 120, "countdown_done": "Happy hour!"},
{"kind": "countdown", "countdown_to": "2026-12-31T23:59"},
{"kind": "hours", "hours_style": "today"},
{"kind": "wifi", "wifi_qr": False},
{"kind": "contact", "contact_fields": ["phone", "instagram"]},
]
s = slide(client, owner_h, p["id"], "blank", content={"widgets": widgets})
got = s["content"]["widgets"]
assert [w["kind"] for w in got] == [w["kind"] for w in widgets]
assert got[0]["shape"] == "star" and got[2]["countdown_before"] == 120 and got[6]["contact_fields"] == ["phone", "instagram"]
bad = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h,
json={"kind": "blank", "content": {"widgets": [{"kind": "countdown", "countdown_to": "5pm"}]}})
assert err(bad) == "signage.content_invalid"
bad = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h,
json={"kind": "blank", "content": {"widgets": [{"kind": "contact", "contact_fields": ["fax"]}]}})
assert err(bad) == "signage.content_invalid"