Browse Source

Fix issue when no rules exist in firewall

Neil Beadle 5 years ago
parent
commit
59227bd299
1 changed files with 6 additions and 5 deletions
  1. 6 5
      vycontrol/firewall/views.py

+ 6 - 5
vycontrol/firewall/views.py

@@ -50,13 +50,14 @@ def index(request):
 
 
 
 
     firewall_all = vyos.get_firewall_all(hostname_default)
     firewall_all = vyos.get_firewall_all(hostname_default)
-    if firewall_all == False or firewall_all['name'] == False:
+    if firewall_all == False:
         return redirect('firewall:firewall-create')
         return redirect('firewall:firewall-create')
 
 
-    for xitem in firewall_all['name']:
-        if 'default-action' in firewall_all['name'][xitem]:
-            firewall_all['name'][xitem]['default_action'] = firewall_all['name'][xitem]['default-action']
-            del firewall_all['name'][xitem]['default-action']
+    if 'name' in firewall_all: 
+        for xitem in firewall_all['name']:
+            if 'default-action' in firewall_all['name'][xitem]:
+                firewall_all['name'][xitem]['default_action'] = firewall_all['name'][xitem]['default-action']
+                del firewall_all['name'][xitem]['default-action']
 
 
     template = loader.get_template('firewall/list.html')
     template = loader.get_template('firewall/list.html')
     context = { 
     context = {