def remove_ip(request): """ Remove an IP address. Should be an AJAX POST. :param request: Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == "POST" and request.is_ajax(): result = ip_remove(request.POST['key'], request.user.username) return HttpResponse(json.dumps(result), mimetype="application/json") return render(request, 'error.html', {'error': 'Expected AJAX/POST'})
def remove_ip(request): """ Remove an IP address. Should be an AJAX POST. :param request: Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == "POST" and request.is_ajax(): result = ip_remove(request.POST['key'], request.user.username) return HttpResponse(json.dumps(result), mimetype="application/json") return render(request, 'error.html', {'error':'Expected AJAX/POST'})
def remove_ip(request): """ Remove an IP address. Should be an AJAX POST. :param request: Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == "POST" and request.is_ajax(): if is_admin(request.user): result = ip_remove(request.POST['key'], request.user.username) return HttpResponse(json.dumps(result), content_type="application/json") error = 'You do not have permission to remove this item.' return render_to_response("error.html", {'error': error}, RequestContext(request)) return render_to_response('error.html', {'error': 'Expected AJAX/POST'}, RequestContext(request))
def remove_ip(request): """ Remove an IP address. Should be an AJAX POST. :param request: Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == "POST" and request.is_ajax(): if is_admin(request.user): result = ip_remove(request.POST['key'], request.user.username) return HttpResponse(json.dumps(result), content_type="application/json") error = 'You do not have permission to remove this item.' return render_to_response("error.html", {'error': error}, RequestContext(request)) return render_to_response('error.html', {'error':'Expected AJAX/POST'}, RequestContext(request))