Development
This commit is contained in:
parent
27f2356cd1
commit
19f0bfa79c
4 changed files with 115 additions and 21 deletions
|
|
@ -35,19 +35,38 @@ def options_save():
|
|||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
@bp.route('/action/captiveportal/splash_save', methods=['POST'])
|
||||
@bp.route('/action/captiveportal/portal_save', methods=['POST'])
|
||||
@auth.require_level('administrator')
|
||||
def splash_save():
|
||||
cfg = config_utils.load_config()
|
||||
before = copy.deepcopy(cfg.get('captive_portal', {}))
|
||||
def portal_save():
|
||||
cfg = config_utils.load_config()
|
||||
vlan_name = sanitize.name(request.form.get('vlan_name', ''))
|
||||
|
||||
splash_text = sanitize.description(request.form.get('splash_text', ''))
|
||||
terms = [t.strip() for t in request.form.getlist('terms') if t.strip()]
|
||||
vlan = next((v for v in cfg.get('vlans', []) if v['name'] == vlan_name), None)
|
||||
if not vlan or vlan.get('restricted_vlan') != 'c':
|
||||
flash('Captive portal VLAN not found.', 'error')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
after = {**before, 'splash_text': splash_text, 'terms': terms}
|
||||
cfg.setdefault('captive_portal', {}).update(after)
|
||||
before = {
|
||||
'portal_splash_title': vlan.get('portal_splash_title', ''),
|
||||
'portal_splash_text': vlan.get('portal_splash_text', ''),
|
||||
'portal_terms': vlan.get('portal_terms', []),
|
||||
}
|
||||
|
||||
splash_title = sanitize.description(request.form.get('portal_splash_title', ''))
|
||||
splash_text = sanitize.description(request.form.get('portal_splash_text', ''))
|
||||
terms = [t.strip() for t in request.form.getlist('portal_terms') if t.strip()]
|
||||
|
||||
vlan['portal_splash_title'] = splash_title
|
||||
vlan['portal_splash_text'] = splash_text
|
||||
vlan['portal_terms'] = terms
|
||||
|
||||
after = {
|
||||
'portal_splash_title': splash_title,
|
||||
'portal_splash_text': splash_text,
|
||||
'portal_terms': terms,
|
||||
}
|
||||
changes = config_utils.diff_fields(before, after)
|
||||
flash(config_utils.record_group(
|
||||
cfg, 'captive_portal', 'setting', 'captive_portal', changes, 'core apply'
|
||||
cfg, 'vlans', 'portal', vlan_name, changes, 'core apply'
|
||||
), 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue