Commit 813d650d by Őry Máté

webui: unique tpl name check in get parameter

parent 35403787
...@@ -51,7 +51,7 @@ urlpatterns = patterns('', ...@@ -51,7 +51,7 @@ urlpatterns = patterns('',
url(r'^ajax/key/delete/$', 'one.views.key_ajax_delete', ), url(r'^ajax/key/delete/$', 'one.views.key_ajax_delete', ),
url(r'^ajax/key/reset/$', 'one.views.key_ajax_reset', ), url(r'^ajax/key/reset/$', 'one.views.key_ajax_reset', ),
url(r'^ajax/template/delete/$', 'one.views.ajax_template_delete', ), url(r'^ajax/template/delete/$', 'one.views.ajax_template_delete', ),
url(r'^ajax/template_name_unique/(?P<name>.*)$', url(r'^ajax/template_name_unique/$',
'one.views.ajax_template_name_unique', ), 'one.views.ajax_template_name_unique', ),
url(r'^reload/$', 'firewall.views.reload_firewall', ), url(r'^reload/$', 'firewall.views.reload_firewall', ),
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
var s = $(self).val(); var s = $(self).val();
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': '/ajax/template_name_unique/' + s, 'url': '{% one.views.ajax_template_name_unique %}?name=' + s,
'success': function(data, b, c) { 'success': function(data, b, c) {
if (s != $("#new-template-name").val()) { if (s != $("#new-template-name").val()) {
return true; return true;
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
e.preventDefault(); e.preventDefault();
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': '/ajax/template_name_unique/' + $("#new-template-name").val(), 'url': '{% one.views.ajax_template_name_unique %}?name=' + $("#new-template-name").val(),
'success': function(data, b, c) { 'success': function(data, b, c) {
if (data == "True") { if (data == "True") {
$("#template-wizard").unbind('submit').submit() $("#template-wizard").unbind('submit').submit()
......
...@@ -84,7 +84,8 @@ def ajax_template_delete(request): ...@@ -84,7 +84,8 @@ def ajax_template_delete(request):
else: else:
return HttpResponse(unicode(_("Unexpected error happened.")), status=404) return HttpResponse(unicode(_("Unexpected error happened.")), status=404)
def ajax_template_name_unique(request, name): def ajax_template_name_unique(request):
name = request.GET['name']
s = "True" s = "True"
if Template.objects.filter(name=name).exists(): if Template.objects.filter(name=name).exists():
s = "False" s = "False"
......
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