Commit e01052c4 by Bence Dányi

firewall_gui: save new vlans

parent bc2a90c8
......@@ -119,7 +119,7 @@ urlpatterns = patterns('',
url(r'^firewall/rules/new/$', 'firewall_gui.views.show_rule'),
url(r'^firewall/hosts/new/$', 'firewall_gui.views.show_host'),
# url(r'^firewall/vlans/save/$', 'firewall_gui.views.save_vlan'),
url(r'^firewall/vlans/new/$', 'firewall_gui.views.show_vlan'),
# url(r'^firewall/vlangroups/save/$', 'firewall_gui.views.save_vlangroup'),
# url(r'^firewall/hostgroups/save/$', 'firewall_gui.views.save_hostgroup'),
# url(r'^firewall/domains/save/$', 'firewall_gui.views.save_domain'),
......
......@@ -320,8 +320,9 @@ def show_host(request, id=None):
return HttpResponse(json.dumps(host), content_type='application/json')
def show_vlan(request, id):
vlan = get_object_or_404(Vlan, id=id)
def show_vlan(request, id=None):
try:
vlan = Vlan.objects.get(id=id)
vlan = {
'id': vlan.id,
'vid': vlan.vid,
......@@ -360,6 +361,30 @@ def show_vlan(request, id):
'name': vlan.name,
} for vlan in vlan.snat_to.all()]
}
except:
vlan = {
'id': None,
'vid': None,
'name': None,
'ipv4': None,
'ipv6': None,
'nat': '',
'description': '',
'comment': '',
'reverse_domain': '',
'dhcp_pool': '',
'interface': '',
'created_at': None,
'modified_at': None,
'owner': {
'name': None,
},
'domain': {
'name': None,
},
'rules': [],
'vlans': []
}
return HttpResponse(json.dumps(vlan), content_type='application/json')
......@@ -589,9 +614,9 @@ def save_vlan(request):
errors = {}
vlan.vid = data['vid']
vlan.name = data['name']
vlan.ipv4 = data['ipv4'].split('/')[0]
vlan.ipv4 = vlan.net4 = data['ipv4'].split('/')[0]
vlan.prefix4 = data['ipv4'].split('/')[1]
vlan.ipv6 = data['ipv6'].split('/')[0]
vlan.ipv6 = vlan.net6 = data['ipv6'].split('/')[0]
vlan.prefix6 = data['ipv6'].split('/')[1]
vlan.snat_ip = data['nat']
vlan.description = data['description']
......
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