Development

This commit is contained in:
Matthew Grotke 2026-05-29 22:53:20 -04:00
parent 8f377b1839
commit 33b639a353
4 changed files with 85 additions and 8 deletions

View file

@ -1,8 +1,10 @@
import os
from pathlib import Path
from flask import Blueprint, request, redirect, flash, session
from auth import require_level
from config_utils import (flush_pending_to_queue, get_dashboard_pending,
revert_snapshot_to_config, queued_msg)
revert_snapshot_to_config, queued_msg,
SNAPSHOTS_DIR, DASHBOARD_PENDING)
_PAGE = Path(__file__).parent.name
@ -48,3 +50,28 @@ def history_revert():
plural = 's' if succeeded != 1 else ''
flash(f'{succeeded} change{plural} reverted.', 'success')
return redirect(f'/{_PAGE}')
@bp.route('/action/actions/history_clear', methods=['POST'])
@require_level('manager')
def history_clear():
count = 0
for fname in os.listdir(SNAPSHOTS_DIR):
fpath = os.path.join(SNAPSHOTS_DIR, fname)
if os.path.isfile(fpath):
os.remove(fpath)
count += 1
plural = 's' if count != 1 else ''
flash(f'History cleared ({count} record{plural} removed).', 'success')
return redirect(f'/{_PAGE}')
@bp.route('/action/actions/pending_dismiss', methods=['POST'])
@require_level('manager')
def pending_dismiss():
if not get_dashboard_pending():
flash('No pending changes to dismiss.', 'info')
return redirect(f'/{_PAGE}')
open(DASHBOARD_PENDING, 'w').close()
flash('Pending changes dismissed.', 'success')
return redirect(f'/{_PAGE}')