Development
This commit is contained in:
parent
59d3d65d18
commit
ac0aa4de22
4 changed files with 98 additions and 113 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from flask import Blueprint, request, redirect, flash, session
|
||||
from auth import require_level
|
||||
from config_utils import (flush_pending_to_queue, flush_selected_to_queue,
|
||||
delete_pending_by_uuids, get_dashboard_pending,
|
||||
from config_utils import (flush_pending_to_queue, get_dashboard_pending,
|
||||
revert_snapshot_to_core,
|
||||
_is_locked, _format_timing, _seconds_until_next_run)
|
||||
|
||||
bp = Blueprint('action_actions', __name__)
|
||||
|
|
@ -36,13 +36,22 @@ def actions_cardpending_applynow():
|
|||
return redirect(_VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/actions_cardpending_revertselected', methods=['POST'])
|
||||
@bp.route('/action/actions_cardhistory_revertselected', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def actions_cardpending_revertselected():
|
||||
def actions_cardhistory_revertselected():
|
||||
selected_uuids = request.form.getlist('selected_uuids')
|
||||
if not selected_uuids:
|
||||
flash('No items selected.', 'info')
|
||||
return redirect(_VIEW)
|
||||
delete_pending_by_uuids(selected_uuids)
|
||||
flash('Selected changes reverted.', 'success')
|
||||
succeeded, failed = 0, 0
|
||||
for uuid in selected_uuids:
|
||||
msg, ok = revert_snapshot_to_core(uuid)
|
||||
if ok:
|
||||
succeeded += 1
|
||||
else:
|
||||
flash(msg, 'error')
|
||||
failed += 1
|
||||
if succeeded:
|
||||
plural = 's' if succeeded != 1 else ''
|
||||
flash(f'{succeeded} change{plural} reverted.', 'success')
|
||||
return redirect(_VIEW)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue