Commit fece1a96 by Bence Dányi

firewall_gui: allow to crete new vlangroup

parent e01052c4
...@@ -388,8 +388,9 @@ def show_vlan(request, id=None): ...@@ -388,8 +388,9 @@ def show_vlan(request, id=None):
return HttpResponse(json.dumps(vlan), content_type='application/json') return HttpResponse(json.dumps(vlan), content_type='application/json')
def show_vlangroup(request, id): def show_vlangroup(request, id=None):
group = get_object_or_404(VlanGroup, id=id) try:
group = VlanGroup.objects.get(id=id)
group = { group = {
'id': group.id, 'id': group.id,
'name': group.name, 'name': group.name,
...@@ -416,10 +417,24 @@ def show_vlangroup(request, id): ...@@ -416,10 +417,24 @@ def show_vlangroup(request, id):
'nat': rule.nat 'nat': rule.nat
} for rule in group.rules.all()] } for rule in group.rules.all()]
} }
except:
group = {
'id': None,
'name': None,
'vlans': [],
'description': '',
'owner': {
'name': None
},
'created_at': None,
'modified_at': None,
'rules': []
}
return HttpResponse(json.dumps(group), content_type='application/json') return HttpResponse(json.dumps(group), content_type='application/json')
def show_hostgroup(request, id): def show_hostgroup(request, id=None):
try:
group = get_object_or_404(Group, id=id) group = get_object_or_404(Group, id=id)
group = { group = {
'id': group.id, 'id': group.id,
...@@ -447,6 +462,19 @@ def show_hostgroup(request, id): ...@@ -447,6 +462,19 @@ def show_hostgroup(request, id):
'nat': rule.nat 'nat': rule.nat
} for rule in group.rules.all()] } for rule in group.rules.all()]
} }
except:
group = {
'id': None,
'name': None,
'description': '',
'owner': {
'name': None,
},
'created_at': None,
'modified_at': None,
'hosts': [],
'rules': []
}
return HttpResponse(json.dumps(group), content_type='application/json') return HttpResponse(json.dumps(group), content_type='application/json')
def show_record(request, id): def show_record(request, id):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment