diff options
Diffstat (limited to 'talerbackoffice/backoffice/backoffice.py')
-rw-r--r-- | talerbackoffice/backoffice/backoffice.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/talerbackoffice/backoffice/backoffice.py b/talerbackoffice/backoffice/backoffice.py index 8b6242b..ef74dd9 100644 --- a/talerbackoffice/backoffice/backoffice.py +++ b/talerbackoffice/backoffice/backoffice.py @@ -17,8 +17,6 @@ # # @author Florian Dold # @author Marcello Stanisci - - """ Implement URL handlers for backoffice logic. """ @@ -61,19 +59,23 @@ LANGUAGES = { 'ru': 'Russian', } + @babel.localeselector def get_locale(): - # If any "lang" component exists in the path, then - # it must be at the second position into the split array. - lang = flask.request.path.split("/")[1] - return lang if lang in LANGUAGES.keys() else "en" + # If any "lang" component exists in the path, then + # it must be at the second position into the split array. + lang = flask.request.path.split("/")[1] + return lang if lang in LANGUAGES.keys() else "en" + @app.context_processor def utility_processor(): def url(my_url): return join_urlparts(flask.request.script_root, my_url) + def env(name, default=None): return os.environ.get(name, default) + return dict(url=url, env=env) @@ -81,7 +83,10 @@ def utility_processor(): @app.route("/", defaults={"lang": "en"}) def index(lang): # 'lang' parameter not used. - return flask.render_template("templates/backoffice.html", instances=INSTANCES.split()) + return flask.render_template( + "templates/backoffice.html", instances=INSTANCES.split() + ) + @app.route("/javascript") def javascript_licensing(): @@ -92,10 +97,11 @@ def javascript_licensing(): def history(): qs = get_query_string().decode("utf-8") url = urljoin(BACKEND_URL, "history") - resp = requests.get(url, - params=dict(parse_qsl(qs)), - headers={"Authorization": - "ApiKey sandbox"}) + resp = requests.get( + url, + params=dict(parse_qsl(qs)), + headers={"Authorization": "ApiKey sandbox"} + ) if resp.status_code != 200: return backend_error(resp) return flask.jsonify(resp.json()), resp.status_code @@ -105,10 +111,11 @@ def history(): def track_transfer(): qs = get_query_string().decode("utf-8") url = urljoin(BACKEND_URL, "track/transfer") - resp = requests.get (url, - params=dict(parse_qsl(qs)), - headers={"Authorization": - "ApiKey sandbox"}) + resp = requests.get( + url, + params=dict(parse_qsl(qs)), + headers={"Authorization": "ApiKey sandbox"} + ) if resp.status_code != 200: return backend_error(resp) return flask.jsonify(resp.json()), resp.status_code @@ -118,10 +125,11 @@ def track_transfer(): def track_order(): qs = get_query_string().decode("utf-8") url = urljoin(BACKEND_URL, "track/transaction") - resp = requests.get(url, - params=dict(parse_qsl(qs)), - headers={"Authorization": - "ApiKey sandbox"}) + resp = requests.get( + url, + params=dict(parse_qsl(qs)), + headers={"Authorization": "ApiKey sandbox"} + ) if resp.status_code != 200: return backend_error(resp) return flask.jsonify(resp.json()), resp.status_code |