Commit 90a22a2f by Bence Dányi

firewall_gui: delete entities

parent 95b82bbb
...@@ -114,4 +114,14 @@ urlpatterns = patterns('', ...@@ -114,4 +114,14 @@ urlpatterns = patterns('',
url(r'^firewall/hostgroups/save/$', 'firewall_gui.views.save_hostgroup'), url(r'^firewall/hostgroups/save/$', 'firewall_gui.views.save_hostgroup'),
url(r'^firewall/domains/save/$', 'firewall_gui.views.save_domain'), url(r'^firewall/domains/save/$', 'firewall_gui.views.save_domain'),
url(r'^firewall/records/save/$', 'firewall_gui.views.save_record'), url(r'^firewall/records/save/$', 'firewall_gui.views.save_record'),
url(r'^firewall/(?P<name>\w+)/(?P<id>\d+)/delete/', 'firewall_gui.views.delete_entity'),
url(r'^firewall/rules/new/$', 'firewall_gui.views.show_rule'),
# url(r'^firewall/hosts/save/$', 'firewall_gui.views.save_host'),
# url(r'^firewall/vlans/save/$', 'firewall_gui.views.save_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'),
# url(r'^firewall/records/save/$', 'firewall_gui.views.save_record'),
) )
...@@ -661,3 +661,19 @@ def save_record(request): ...@@ -661,3 +661,19 @@ def save_record(request):
return HttpResponse(json.dumps(errors), content_type='application/json', status=400) return HttpResponse(json.dumps(errors), content_type='application/json', status=400)
record.save() record.save()
return HttpResponse('KTHXBYE') return HttpResponse('KTHXBYE')
@user_passes_test(req_staff)
def delete_entity(request, name, id):
model = {
'rules': Rule,
'hosts': Host,
'hostgroups': Group,
'vlans': Vlan,
'vlangroups': VlanGroup,
'firewalls': Firewall,
'domains': Domain,
'records': Record,
'blacklists': Blacklist
}[name]
model.objects.get(id=id).delete()
return HttpResponse('KTHXBYE')
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