diff --git a/web/pgadmin/utils/ajax.py b/web/pgadmin/utils/ajax.py index 45416b33b..1b2754ffa 100644 --- a/web/pgadmin/utils/ajax.py +++ b/web/pgadmin/utils/ajax.py @@ -10,6 +10,7 @@ """Utility functions for dealing with AJAX.""" from flask import Response +from flask.ext.babel import gettext as _ import json @@ -25,28 +26,28 @@ def make_json_response(success=1, errormsg='', info='', result=None, doc['data'] = data return Response( - response=json.dumps(doc), - status=status, - mimetype="text/json" - ) + response=json.dumps(doc), + status=status, + mimetype="text/json" + ) def make_response(response=None, status=200): """Create a JSON response handled by the backbone models.""" return Response( - response=json.dumps(response), - status=status, - mimetype="text/json" - ) + response=json.dumps(response), + status=status, + mimetype="text/json" + ) def internal_server_error(errormsg=''): """Create a response with HTTP status code 500 - Internal Server Error.""" return make_json_response( - status=500, - success=0, - errormsg=errormsg - ) + status=500, + success=0, + errormsg=errormsg + ) def forbidden(errmsg=''): @@ -61,42 +62,52 @@ def forbidden(errmsg=''): def unauthorized(errormsg=''): """Create a response with HTTP status code 401 - Unauthorized.""" return make_json_response( - status=401, - success=0, - errormsg=errormsg - ) + status=401, + success=0, + errormsg=errormsg + ) def bad_request(errormsg=''): """Create a response with HTTP status code 400 - Bad Request.""" return make_json_response( - status=400, - success=0, - errormsg=errormsg - ) + status=400, + success=0, + errormsg=errormsg + ) def precondition_required(errormsg=''): """Create a response with HTTP status code 428 - Precondition Required.""" return make_json_response( - status=428, - success=0, - errormsg=errormsg - ) + status=428, + success=0, + errormsg=errormsg + ) def success_return(message=''): """Create a response with HTTP status code 200 - OK.""" return make_json_response( - status=200, - success=1, - info=message - ) + status=200, + success=1, + info=message + ) + def gone(errormsg=''): """Create a response with HTTP status code 410 - GONE.""" return make_json_response( - status=410, - success=0, - errormsg=errormsg - ) + status=410, + success=0, + errormsg=errormsg + ) + + +def not_implemented(errormsg=_('It is not implemented!')): + """Create a response with HTTP status code 501 - Not Implemented.""" + return make_json_response( + status=501, + success=0, + errormsg=errormsg + )