Commit fece1a96 by Bence Dányi

firewall_gui: allow to crete new vlangroup

parent e01052c4
......@@ -388,65 +388,93 @@ 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)
group = {
'id': group.id,
'name': group.name,
'vlans': [{
'id': vlan.id,
'name': vlan.name
} for vlan in group.vlans.all()],
'description': group.description,
'owner': {
'id': group.owner.id,
'name': str(group.owner)
},
'created_at': group.created_at.isoformat(),
'modified_at': group.modified_at.isoformat(),
'rules': [{
'id': rule.id,
'direction': rule.get_direction_display(),
'proto': rule.proto,
def show_vlangroup(request, id=None):
try:
group = VlanGroup.objects.get(id=id)
group = {
'id': group.id,
'name': group.name,
'vlans': [{
'id': vlan.id,
'name': vlan.name
} for vlan in group.vlans.all()],
'description': group.description,
'owner': {
'id': rule.owner.id,
'name': str(rule.owner),
'id': group.owner.id,
'name': str(group.owner)
},
'accept': rule.accept,
'nat': rule.nat
} for rule in group.rules.all()]
}
'created_at': group.created_at.isoformat(),
'modified_at': group.modified_at.isoformat(),
'rules': [{
'id': rule.id,
'direction': rule.get_direction_display(),
'proto': rule.proto,
'owner': {
'id': rule.owner.id,
'name': str(rule.owner),
},
'accept': rule.accept,
'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):
group = get_object_or_404(Group, id=id)
group = {
'id': group.id,
'name': group.name,
'description': group.description,
'owner': {
'id': group.owner.id,
'name': str(group.owner),
},
'created_at': group.created_at.isoformat(),
'modified_at': group.modified_at.isoformat(),
'hosts': [{
'id': host.id,
'name': host.hostname
} for host in group.host_set.all()],
'rules': [{
'id': rule.id,
'direction': rule.get_direction_display(),
'proto': rule.proto,
def show_hostgroup(request, id=None):
try:
group = get_object_or_404(Group, id=id)
group = {
'id': group.id,
'name': group.name,
'description': group.description,
'owner': {
'id': rule.owner.id,
'name': str(rule.owner),
'id': group.owner.id,
'name': str(group.owner),
},
'accept': rule.accept,
'nat': rule.nat
} for rule in group.rules.all()]
}
'created_at': group.created_at.isoformat(),
'modified_at': group.modified_at.isoformat(),
'hosts': [{
'id': host.id,
'name': host.hostname
} for host in group.host_set.all()],
'rules': [{
'id': rule.id,
'direction': rule.get_direction_display(),
'proto': rule.proto,
'owner': {
'id': rule.owner.id,
'name': str(rule.owner),
},
'accept': rule.accept,
'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