linuxrouter/docker/routlin-dash/app/action_actions.py

44 lines
1.5 KiB
Python
Raw Normal View History

2026-05-25 13:49:23 -04:00
from flask import Blueprint, request, redirect, flash, session
2026-05-23 00:27:37 -04:00
from auth import require_level
2026-05-25 13:49:23 -04:00
from config_utils import (flush_pending_to_queue, get_dashboard_pending,
2026-05-23 00:27:37 -04:00
_is_locked, _format_timing, _seconds_until_next_run)
2026-05-25 13:49:23 -04:00
bp = Blueprint('action_actions', __name__)
2026-05-23 00:27:37 -04:00
2026-05-25 13:49:23 -04:00
_VIEW = '/view/view_actions'
2026-05-23 00:27:37 -04:00
@bp.route('/action/general_cardpendingchanges_save', methods=['POST'])
@require_level('administrator')
def general_cardpendingchanges_save():
2026-05-25 13:49:23 -04:00
session['apply_changes_immediately'] = 'apply_changes_immediately' in request.form
flash('Preference saved.', 'success')
2026-05-23 00:27:37 -04:00
return redirect(_VIEW)
@bp.route('/action/general_cardpendingchanges_applyselected', methods=['POST'])
@require_level('administrator')
def general_cardpendingchanges_applyselected():
items = get_dashboard_pending()
if not items:
flash('No pending changes to apply.', 'info')
return redirect(_VIEW)
flush_pending_to_queue()
if _is_locked():
msg = 'Changes queued. They are being applied now.'
else:
timing = _format_timing(_seconds_until_next_run())
if timing:
msg = f'Changes queued. They will be applied {timing}.'
else:
msg = 'Changes queued. The processing service is not running.'
flash(msg, 'success')
return redirect(_VIEW)
@bp.route('/action/general_cardpendingchanges_deleteselected', methods=['POST'])
@require_level('administrator')
def general_cardpendingchanges_deleteselected():
flash('Not yet implemented.', 'info')
return redirect(_VIEW)