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):
return HttpResponse(json.dumps(vlan), content_type='application/json')
def show_vlangroup(request, id):
group = get_object_or_404(VlanGroup, id=id)
def show_vlangroup(request, id=None):
try:
group = VlanGroup.objects.get(id=id)
group = {
'id': group.id,
'name': group.name,
......@@ -416,10 +417,24 @@ def show_vlangroup(request, id):
'nat': rule.nat
} 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')
def show_hostgroup(request, id):
def show_hostgroup(request, id=None):
try:
group = get_object_or_404(Group, id=id)
group = {
'id': group.id,
......@@ -447,6 +462,19 @@ def show_hostgroup(request, id):
'nat': rule.nat
} 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')
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