Development
This commit is contained in:
parent
d5dfb637fc
commit
2e4921ab73
4 changed files with 48 additions and 1 deletions
|
|
@ -89,6 +89,13 @@ def blocklists_delete():
|
|||
before = copy.deepcopy(items[idx])
|
||||
name = before.get('name', str(idx))
|
||||
items.pop(idx)
|
||||
|
||||
for vlan in cfg.get('vlans', []):
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if name in current:
|
||||
current.discard(name)
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
@ -152,6 +159,19 @@ def blocklists_edit():
|
|||
items[idx]['save_as'] = _save_as_from_name(fields['name'], 'conf')
|
||||
items[idx].pop('local_lines', None)
|
||||
|
||||
old_name = before.get('name', '')
|
||||
used_by_vlans = set(request.form.getlist('used_by_vlans'))
|
||||
for vlan in cfg.get('vlans', []):
|
||||
vlan_name = vlan.get('name', '')
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if old_name and old_name != fields['name']:
|
||||
current.discard(old_name)
|
||||
if vlan_name in used_by_vlans:
|
||||
current.add(fields['name'])
|
||||
else:
|
||||
current.discard(fields['name'])
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
@ -202,6 +222,17 @@ def addblocklist_add():
|
|||
}
|
||||
|
||||
blocklists.append(entry)
|
||||
|
||||
used_by_vlans = set(request.form.getlist('used_by_vlans'))
|
||||
for vlan in cfg.get('vlans', []):
|
||||
vlan_name = vlan.get('name', '')
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if vlan_name in used_by_vlans:
|
||||
current.add(fields['name'])
|
||||
else:
|
||||
current.discard(fields['name'])
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue