Add edit_on_player_enabled feature for playlist content
- Added edit_on_player_enabled column to playlist_content table - Updated playlist model to track edit enablement per content item - Added UI checkbox on upload media page to enable/disable editing - Added toggle column on manage playlist page for existing content - Updated API endpoint to return edit_on_player_enabled flag to players - Fixed docker-entrypoint.sh to use production config - Supports PDF, Images, and PPTX content types
This commit is contained in:
@@ -396,6 +396,47 @@ def update_playlist_content_muted(playlist_id: int, content_id: int):
|
||||
return jsonify({'success': False, 'message': str(e)}), 500
|
||||
|
||||
|
||||
@content_bp.route('/playlist/<int:playlist_id>/update-edit-enabled/<int:content_id>', methods=['POST'])
|
||||
@login_required
|
||||
def update_playlist_content_edit_enabled(playlist_id: int, content_id: int):
|
||||
"""Update content edit_on_player_enabled setting in playlist."""
|
||||
playlist = Playlist.query.get_or_404(playlist_id)
|
||||
|
||||
try:
|
||||
content = Content.query.get_or_404(content_id)
|
||||
edit_enabled = request.form.get('edit_enabled', 'false').lower() == 'true'
|
||||
|
||||
from app.models.playlist import playlist_content
|
||||
from sqlalchemy import update
|
||||
|
||||
# Update edit_on_player_enabled in association table
|
||||
stmt = update(playlist_content).where(
|
||||
(playlist_content.c.playlist_id == playlist_id) &
|
||||
(playlist_content.c.content_id == content_id)
|
||||
).values(edit_on_player_enabled=edit_enabled)
|
||||
db.session.execute(stmt)
|
||||
|
||||
# Increment playlist version
|
||||
playlist.increment_version()
|
||||
|
||||
db.session.commit()
|
||||
cache.clear()
|
||||
|
||||
log_action('info', f'Updated edit_on_player_enabled={edit_enabled} for "{content.filename}" in playlist "{playlist.name}"')
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': 'Edit setting updated',
|
||||
'edit_enabled': edit_enabled,
|
||||
'version': playlist.version
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
log_action('error', f'Error updating edit setting: {str(e)}')
|
||||
return jsonify({'success': False, 'message': str(e)}), 500
|
||||
|
||||
|
||||
@content_bp.route('/upload-media-page')
|
||||
@login_required
|
||||
def upload_media_page():
|
||||
@@ -527,7 +568,7 @@ def process_pdf_file(filepath: str, filename: str) -> tuple[bool, str]:
|
||||
|
||||
|
||||
def process_file_in_background(app, filepath: str, filename: str, file_ext: str,
|
||||
duration: int, playlist_id: Optional[int], task_id: str):
|
||||
duration: int, playlist_id: Optional[int], task_id: str, edit_on_player_enabled: bool = False):
|
||||
"""Process large files (PDF, PPTX, Video) in background thread."""
|
||||
with app.app_context():
|
||||
try:
|
||||
@@ -573,7 +614,8 @@ def process_file_in_background(app, filepath: str, filename: str, file_ext: str,
|
||||
playlist_id=playlist_id,
|
||||
content_id=page_content.id,
|
||||
position=max_position,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
|
||||
@@ -629,7 +671,8 @@ def process_file_in_background(app, filepath: str, filename: str, file_ext: str,
|
||||
playlist_id=playlist_id,
|
||||
content_id=slide_content.id,
|
||||
position=max_position,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
|
||||
@@ -677,7 +720,8 @@ def process_file_in_background(app, filepath: str, filename: str, file_ext: str,
|
||||
playlist_id=playlist_id,
|
||||
content_id=content.id,
|
||||
position=max_position + 1,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
playlist.version += 1
|
||||
@@ -949,6 +993,7 @@ def upload_media():
|
||||
content_type = request.form.get('content_type', 'image')
|
||||
duration = request.form.get('duration', type=int, default=10)
|
||||
playlist_id = request.form.get('playlist_id', type=int)
|
||||
edit_on_player_enabled = request.form.get('edit_on_player_enabled', '0') == '1'
|
||||
|
||||
if not files or files[0].filename == '':
|
||||
flash('No files provided.', 'warning')
|
||||
@@ -991,7 +1036,7 @@ def upload_media():
|
||||
|
||||
thread = threading.Thread(
|
||||
target=process_file_in_background,
|
||||
args=(current_app._get_current_object(), filepath, filename, file_ext, duration, playlist_id, task_id)
|
||||
args=(current_app._get_current_object(), filepath, filename, file_ext, duration, playlist_id, task_id, edit_on_player_enabled)
|
||||
)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
@@ -1054,7 +1099,8 @@ def upload_media():
|
||||
playlist_id=playlist_id,
|
||||
content_id=page_content.id,
|
||||
position=max_position,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
|
||||
@@ -1113,7 +1159,8 @@ def upload_media():
|
||||
playlist_id=playlist_id,
|
||||
content_id=slide_content.id,
|
||||
position=max_position,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
|
||||
@@ -1165,7 +1212,8 @@ def upload_media():
|
||||
playlist_id=playlist_id,
|
||||
content_id=content.id,
|
||||
position=max_position + 1,
|
||||
duration=duration
|
||||
duration=duration,
|
||||
edit_on_player_enabled=edit_on_player_enabled
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user