updated pages
This commit is contained in:
@@ -207,6 +207,55 @@ def get_player_content_status(player_id):
|
||||
except Exception as e:
|
||||
return jsonify({'error': f'Failed to get content status: {str(e)}'}), 500
|
||||
|
||||
@bp.route('/content/<int:content_id>/edit', methods=['POST'])
|
||||
def edit_content_duration(content_id):
|
||||
"""Edit content duration"""
|
||||
from flask_login import current_user
|
||||
|
||||
# Require authentication for this operation
|
||||
if not current_user.is_authenticated:
|
||||
return jsonify({'error': 'Authentication required'}), 401
|
||||
|
||||
data = request.get_json()
|
||||
if not data or 'duration' not in data:
|
||||
return jsonify({'error': 'Duration required'}), 400
|
||||
|
||||
new_duration = data.get('duration')
|
||||
|
||||
# Validate duration
|
||||
try:
|
||||
new_duration = int(new_duration)
|
||||
if new_duration < 1 or new_duration > 300:
|
||||
return jsonify({'error': 'Duration must be between 1 and 300 seconds'}), 400
|
||||
except (ValueError, TypeError):
|
||||
return jsonify({'error': 'Invalid duration value'}), 400
|
||||
|
||||
# Find the content item
|
||||
content = Content.query.get(content_id)
|
||||
if not content:
|
||||
return jsonify({'error': 'Content not found'}), 404
|
||||
|
||||
# Update the content duration
|
||||
try:
|
||||
old_duration = content.duration
|
||||
content.duration = new_duration
|
||||
|
||||
# Update player's playlist version to trigger refresh
|
||||
player = Player.query.get(content.player_id)
|
||||
if player:
|
||||
player.increment_playlist_version()
|
||||
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': f'Content duration updated from {old_duration}s to {new_duration}s',
|
||||
'new_duration': new_duration
|
||||
})
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({'error': f'Failed to update content: {str(e)}'}), 500
|
||||
|
||||
@bp.errorhandler(404)
|
||||
def api_not_found(error):
|
||||
"""API 404 handler"""
|
||||
|
||||
Reference in New Issue
Block a user