- 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>
71 lines
2.9 KiB
Python
71 lines
2.9 KiB
Python
"""Signage playlists and slides (plan step 5.4a); media.builtin for pictures shipped with the server.
|
|
|
|
Revision ID: 0029_signage
|
|
Revises: 0028_display_looks
|
|
Create Date: 2026-11-17 20:00:00
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from core.timeutil import UTCDateTime
|
|
|
|
revision = '0029_signage'
|
|
down_revision = '0028_display_looks'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table('signage_playlists',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.Column('orientation', sa.String(), nullable=False),
|
|
sa.Column('transition', sa.String(), nullable=False),
|
|
sa.Column('created_at', UTCDateTime(), nullable=False),
|
|
sa.Column('updated_at', UTCDateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('signage_playlists', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_signage_playlists_id'), ['id'], unique=False)
|
|
|
|
op.create_table('signage_slides',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('playlist_id', sa.Integer(), nullable=False),
|
|
sa.Column('position', sa.Integer(), nullable=False),
|
|
sa.Column('kind', sa.String(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=True),
|
|
sa.Column('duration_s', sa.Integer(), nullable=False),
|
|
sa.Column('transition', sa.String(), nullable=True),
|
|
sa.Column('video_to_end', sa.Boolean(), nullable=False),
|
|
sa.Column('enabled', sa.Boolean(), nullable=False),
|
|
sa.Column('days', sa.JSON(), nullable=True),
|
|
sa.Column('time_from', sa.String(), nullable=True),
|
|
sa.Column('time_to', sa.String(), nullable=True),
|
|
sa.Column('date_from', sa.String(), nullable=True),
|
|
sa.Column('date_to', sa.String(), nullable=True),
|
|
sa.Column('content', sa.JSON(), nullable=False),
|
|
sa.ForeignKeyConstraint(['playlist_id'], ['signage_playlists.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('signage_slides', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_signage_slides_id'), ['id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_signage_slides_playlist_id'), ['playlist_id'], unique=False)
|
|
|
|
with op.batch_alter_table('media', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('builtin', sa.Boolean(), server_default='0', nullable=False))
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table('media', schema=None) as batch_op:
|
|
batch_op.drop_column('builtin')
|
|
|
|
with op.batch_alter_table('signage_slides', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_signage_slides_playlist_id'))
|
|
batch_op.drop_index(batch_op.f('ix_signage_slides_id'))
|
|
|
|
op.drop_table('signage_slides')
|
|
with op.batch_alter_table('signage_playlists', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_signage_playlists_id'))
|
|
|
|
op.drop_table('signage_playlists')
|