feat(backend): signage playlists and slides, screens, built-in pictures (platform-v2 step 5.4a)

- signage_playlists (name, orientation, default transition) and
  signage_slides (kind menu | image | video | text, position, duration,
  transition, video to its end, on/off, days / hours / dates, content typed
  per kind: extra fields refused, pictures / videos as media ids). Alembic 0029.
- /api/signage: playlists CRUD, duplicate, timeline order; slides add (at a
  position), change, delete, duplicate; screens (playlist, orientation,
  rotation, orientation mismatch). The screen's GET /api/signage/screen gives
  its playlist resolved for playing with a version hash. Changes send
  signage.changed only to the screens playing that playlist.
- Signage device config: playlist (ref signage_playlists), orientation,
  rotation. Slides register their media usage.
- Built-in pictures: assets/builtin_media/ imported at start
  (media.builtin), a collection of their own (?collection=builtin|own),
  never deleted or renamed (media.builtin).
- tests: test_signage.py (8); 509 passed. Pack README: the signage row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 18:35:13 +02:00
co-authored by Claude Opus 5.5
parent 51b764fe7e
commit 7fc32ad917
18 changed files with 951 additions and 7 deletions
+1
View File
@@ -40,3 +40,4 @@ import models.fees # noqa: F401 DeliveryArea, FeeRule (phase 3S, S.3)
import models.refund # noqa: F401 Refund, RefundItem (step 3.3e)
import models.media # noqa: F401 Media (media library, step 5.1)
import models.display_look # noqa: F401 DisplayLook (customer display looks, step 5.3)
import models.signage # noqa: F401 SignagePlaylist, SignageSlide (signage, step 5.4a)
+3 -1
View File
@@ -10,7 +10,7 @@ Rows are referenced by id from what uses them (products, the customer display, s
steps 5.2-5.4). Those users register a usage check in services/media.py so a file in use
can't be deleted.
"""
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from core.timeutil import UTCDateTime, utcnow
@@ -32,6 +32,8 @@ class Media(Base):
duration_ms = Column(Integer, nullable=True) # videos (MP4) when the file says
uploaded_by = Column(Integer, ForeignKey("users.id", ondelete="SET NULL"), nullable=True)
created_at = Column(UTCDateTime, default=utcnow, nullable=False)
# Shipped with the server (assets/builtin_media, step 5.4a): can't be deleted or renamed
builtin = Column(Boolean, nullable=False, default=False, server_default='0')
uploader = relationship("User", lazy="joined")
+53
View File
@@ -0,0 +1,53 @@
"""Digital signage (plan steps 5.4a-5.4d): playlists of slides for TVs.
A playlist is made for one orientation (the people who build it see the screen's shape) and
holds slides in order. A slide is a menu board, a full-screen picture, a full-screen video or
a text, with its time on screen, its transition and when it may show (days, hours, dates).
What the slide shows is `content`, typed per kind in routers/signage.py (pictures and videos
as media library ids, which the library protects while used).
A paired signage screen plays the playlist in its device config (`playlist`), in its own
orientation and rotation (modules/signage/manifest.py).
"""
from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from core.timeutil import UTCDateTime, utcnow
from database import Base
class SignagePlaylist(Base):
__tablename__ = "signage_playlists"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
orientation = Column(String, nullable=False, default="landscape") # landscape | portrait
transition = Column(String, nullable=False, default="fade") # the slides' default
created_at = Column(UTCDateTime, default=utcnow, nullable=False)
updated_at = Column(UTCDateTime, default=utcnow, onupdate=utcnow, nullable=False)
slides = relationship("SignageSlide", back_populates="playlist", cascade="all, delete-orphan",
order_by="SignageSlide.position")
class SignageSlide(Base):
__tablename__ = "signage_slides"
id = Column(Integer, primary_key=True, index=True)
playlist_id = Column(Integer, ForeignKey("signage_playlists.id", ondelete="CASCADE"), nullable=False, index=True)
position = Column(Integer, nullable=False, default=0)
kind = Column(String, nullable=False) # menu | image | video | text
name = Column(String, nullable=True) # the timeline's label (optional)
duration_s = Column(Integer, nullable=False, default=10)
transition = Column(String, nullable=True) # None: the playlist's
video_to_end = Column(Boolean, nullable=False, default=False)
enabled = Column(Boolean, nullable=False, default=True)
# When it may show (venue time); empty = always
days = Column(JSON, nullable=True) # [0..6], Monday = 0
time_from = Column(String, nullable=True) # "HH:MM"
time_to = Column(String, nullable=True) # "HH:MM" (may pass midnight)
date_from = Column(String, nullable=True) # "YYYY-MM-DD"
date_to = Column(String, nullable=True)
content = Column(JSON, nullable=False, default=dict)
playlist = relationship("SignagePlaylist", back_populates="slides")