summaryrefslogtreecommitdiff
path: root/talermerchantdemos/survey/survey.py
diff options
context:
space:
mode:
Diffstat (limited to 'talermerchantdemos/survey/survey.py')
-rw-r--r--talermerchantdemos/survey/survey.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/talermerchantdemos/survey/survey.py b/talermerchantdemos/survey/survey.py
index 140088d..38065f1 100644
--- a/talermerchantdemos/survey/survey.py
+++ b/talermerchantdemos/survey/survey.py
@@ -57,13 +57,11 @@ app.config.from_object(__name__)
babel = Babel(app)
INSTANCED_URL = urljoin(BACKEND_URL, f"instances/survey/")
-print("Using translations from:")
-print(list(babel.translation_directories))
+LOGGER.info("Using translations from:" + ':'.join(list(babel.translation_directories)))
translations = [str(translation) for translation in babel.list_translations()]
if not 'en' in translations:
translations.append('en')
-print("Operating with the following translations available:")
-print(translations)
+LOGGER.info("Operating with the following translations available: " + ' '.join(translations))
app.jinja_env.globals.update(self_localized=self_localized)
@@ -110,10 +108,10 @@ def internal_error(e):
return flask.render_template(
"templates/error.html.j2",
message=gettext("Internal error"),
- stack=traceback.format_exc()
+ stack=traceback.format_exc(),
+ lang=get_locale()
)
-
##
# Serve the /favicon.ico requests.
#
@@ -133,7 +131,10 @@ def favicon():
# @param abort_status_code status code to return along the response.
# @param params _kw_ arguments to passed verbatim to the templating engine.
def err_abort(abort_status_code, **params):
- t = flask.render_template("templates/error.html.j2", **params)
+ t = flask.render_template(
+ "templates/error.html.j2",
+ lang=get_locale(),
+ **params)
flask.abort(flask.make_response(t, abort_status_code))
##
@@ -144,8 +145,8 @@ def err_abort(abort_status_code, **params):
# @return the URL where to redirect the browser, in order
# for the wallet to pick the tip up, or a error page
# otherwise.
-@app.route("/submit-survey", methods=["POST"])
-def submit_survey():
+@app.route("/<lang>/submit-survey", methods=["POST"])
+def submit_survey(lang):
tip_spec = dict(
amount=CURRENCY + ":1.0",
next_url=os.environ.get("TALER_ENV_URL_INTRO", "https://taler.net/"),
@@ -177,4 +178,15 @@ def start(lang):
@app.errorhandler(404)
def handler(e):
return flask.render_template(
- "templates/error.html.j2", message=gettext("Page not found"))
+ "templates/error.html.j2",
+ message=gettext("Page not found"),
+ lang=get_locale()
+ )
+
+@app.errorhandler(405)
+def handler(e):
+ return flask.render_template(
+ "templates/error.html.j2",
+ message=gettext("HTTP method not allowed for this page"),
+ lang=get_locale()
+ )