from flask import Blueprint, redirect, flash from auth import require_level from config_utils import (flush_pending_to_queue, get_dashboard_pending, _is_locked, _format_timing, _seconds_until_next_run) bp = Blueprint('action_apply_pending', __name__) @bp.route('/action/apply_pending', methods=['POST']) @require_level('administrator') def apply_pending(): items = get_dashboard_pending() if not items: flash('No pending changes to apply.', 'info') return redirect('/view/view_general') 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/view_general')