feat(backend): signage previews for the editor: menu boards resolved, a draft menu, the widgets' venue (platform-v2 step 5.6a)

GET /api/signage/playlists/{id} gives each menu slide its resolved `menu`;
POST /api/signage/preview/menu resolves a menu board not saved yet; GET
/api/signage/venue gives what the widgets show. 527 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:59:33 +02:00
co-authored by Claude Opus 5.5
parent 314e9c2457
commit 4d63216167
2 changed files with 36 additions and 0 deletions
+25
View File
@@ -390,7 +390,11 @@ def _playlist_out(db, p: SignagePlaylist, slides: bool = False) -> dict:
out = {"id": p.id, "name": p.name, "orientation": p.orientation, "transition": p.transition,
"slide_count": len(p.slides), "screens": [{"id": d.id, "name": d.name} for d in _screens(db) if d.id in playing]}
if slides:
from services.signage_menu import resolve
out["slides"] = [_slide_out(s) for s in p.slides]
for s in out["slides"]:
if s["kind"] == "menu":
s["menu"] = resolve(db, s["content"]) # the editor's preview (5.6a)
out["media"] = _media_map(db, [i for s in p.slides for i in media_ids(s.content or {})])
return out
@@ -811,3 +815,24 @@ async def weather_places(q: str, language: str = "en", user=Depends(require(KEY)
return await weather.search(q.strip(), language if language in ("en", "el") else "en")
except Exception:
raise XeniaError("signage.weather_offline")
# ── for the editor's previews (5.6a) ───────────────────────────────────────────
class MenuPreviewBody(BaseModel):
content: dict = Field(default_factory=dict)
@router.get("/venue")
def preview_venue(db: Session = Depends(get_db), user=Depends(require(KEY))):
"""What the widgets show (the same as a screen gets), for the editor's previews."""
from services import weather
return {"name": _setting(db, "venue.name") or None, "message": _setting(db, MESSAGE) or None, "weather": weather.current(db)}
@router.post("/preview/menu")
def preview_menu(body: MenuPreviewBody, db: Session = Depends(get_db), user=Depends(require(KEY))):
"""A menu board not saved yet, resolved like a screen gets it (the editor's live preview)."""
from services.signage_menu import resolve
content = _content(db, "menu", body.content)
return {"content": content, "menu": resolve(db, content)}