From c8730857293c694449110ec289210e7ec4f32aa4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 21 Apr 2021 21:35:55 +0200 Subject: make language and active page available in all templates --- talermerchantdemos/survey/survey.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'talermerchantdemos/survey') diff --git a/talermerchantdemos/survey/survey.py b/talermerchantdemos/survey/survey.py index 4813477..1b06218 100644 --- a/talermerchantdemos/survey/survey.py +++ b/talermerchantdemos/survey/survey.py @@ -103,7 +103,13 @@ def utility_processor(): # returns the YYYY-MM-DD date format. return timestamp.strftime("%Y-%b-%d") - return dict(env=env, prettydate=prettydate) + def getactive(): + return "survey" + + def getlang(): + return get_locale() + + return dict(env=env, prettydate=prettydate, getactive=getactive, getlang=getlang) ## @@ -118,7 +124,6 @@ def internal_error(e): "survey-error.html.j2", message=gettext("Internal error"), stack=traceback.format_exc(), - lang=get_locale(), ) @@ -151,7 +156,9 @@ def submit_survey(lang): next_url=os.environ.get("TALER_ENV_URL_INTRO", "https://taler.net/"), justification="Payment methods survey", ) - backend_resp = backend_post(INSTANCED_URL, "private/tips", tip_spec, auth_token=APIKEY) + backend_resp = backend_post( + INSTANCED_URL, "private/tips", tip_spec, auth_token=APIKEY + ) return flask.redirect(backend_resp["tip_status_url"]) @@ -173,14 +180,16 @@ def index(): @app.route("//", methods=["GET"]) def start(lang): return flask.render_template( - "survey-index.html.j2", merchant_currency=CURRENCY, lang=lang + "survey-index.html.j2", + merchant_currency=CURRENCY, ) @app.errorhandler(404) def handler_404(e): return flask.render_template( - "survey-error.html.j2", message=gettext("Page not found"), lang=get_locale() + "survey-error.html.j2", + message=gettext("Page not found"), ) @@ -189,7 +198,6 @@ def handler_405(e): return flask.render_template( "survey-error.html.j2", message=gettext("HTTP method not allowed for this page"), - lang=get_locale(), ) @@ -197,7 +205,6 @@ def handler_405(e): def handler_backend_exception(e): t = flask.render_template( "survey-error.html.j2", - lang=get_locale(), message=e.args[0], json=e.backend_json, status_code=e.backend_status, -- cgit v1.2.3