Development

This commit is contained in:
Matthew Grotke 2026-05-25 13:49:23 -04:00
parent 68b98102cf
commit a78df48804
7 changed files with 33 additions and 29 deletions

View file

@ -1,27 +1,18 @@
from flask import Blueprint, request, redirect, flash
from flask import Blueprint, request, redirect, flash, session
from auth import require_level
from config_utils import (load_core, save_core, verify_core_hash, queued_msg,
flush_pending_to_queue, get_dashboard_pending,
from config_utils import (flush_pending_to_queue, get_dashboard_pending,
_is_locked, _format_timing, _seconds_until_next_run)
import validation as validate
bp = Blueprint('action_general', __name__)
bp = Blueprint('action_actions', __name__)
_VIEW = '/view/view_general'
_VIEW = '/view/view_actions'
@bp.route('/action/general_cardpendingchanges_save', methods=['POST'])
@require_level('administrator')
def general_cardpendingchanges_save():
if not verify_core_hash(request.form.get('config_hash', '')):
flash('Configuration was modified by another session. Please refresh and try again.', 'error')
return redirect(_VIEW)
core = load_core()
core.setdefault('network_interfaces', {})['apply_on_save'] = 'apply_on_save' in request.form
save_core(core)
flash(queued_msg('core apply'), 'success')
session['apply_changes_immediately'] = 'apply_changes_immediately' in request.form
flash('Preference saved.', 'success')
return redirect(_VIEW)

View file

@ -50,6 +50,7 @@ def log_in():
session['email_address'] = account['email_address']
session['access_level'] = account.get('access_level', 'viewer')
session['timezone'] = account.get('timezone', '')
session['apply_changes_immediately'] = False
session.permanent = True
return redirect('/view/view_overview')

View file

@ -111,9 +111,9 @@ def _trim_if_needed():
def _apply_on_save():
try:
return load_core().get('network_interfaces', {}).get('apply_on_save', True)
return session.get('apply_changes_immediately', False)
except Exception:
return True
return False
def _read_dashboard_pending():

View file

@ -1,7 +1,7 @@
import os, json, sys
from flask import Flask
from view_page import bp as view_page_bp
from action_general import bp as action_general_bp
from action_actions import bp as action_actions_bp
from action_networkinterfaces import bp as action_networkinterfaces_bp
from action_upstreamdns import bp as action_upstreamdns_bp
from action_apply_mdns import bp as action_apply_mdns_bp
@ -27,7 +27,7 @@ from api_apply_health import bp as api_apply_health_bp
app = Flask(__name__)
app.secret_key = os.environ.get('SECRET_KEY', os.urandom(24))
app.register_blueprint(view_page_bp)
app.register_blueprint(action_general_bp)
app.register_blueprint(action_actions_bp)
app.register_blueprint(action_networkinterfaces_bp)
app.register_blueprint(action_upstreamdns_bp)
app.register_blueprint(action_apply_mdns_bp)

View file

@ -589,7 +589,7 @@ def collect_tokens():
tokens['GENERAL_LOG_ERRORS_ONLY'] = 'true' if dns_blk_gen.get('log_errors_only') else 'false'
tokens['GENERAL_DAILY_EXECUTE_TIME'] = str(dns_blk_gen.get('daily_execute_time_24hr_local', '-'))
tokens['GENERAL_APPLY_ON_SAVE'] = 'true' if net.get('apply_on_save', True) else 'false'
tokens['GENERAL_APPLY_ON_SAVE'] = 'true' if session.get('apply_changes_immediately', False) else 'false'
pending_items = get_dashboard_pending()
if pending_items: