diff options
author | Florian Dold <florian@dold.me> | 2021-04-22 13:57:43 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-04-22 13:57:43 +0200 |
commit | 58a059b94afee29767303b399b48629985a48942 (patch) | |
tree | b82d875c06fa1e81439bd251604f8014816136d9 /talermerchantdemos/donations | |
parent | c8730857293c694449110ec289210e7ec4f32aa4 (diff) | |
download | taler-merchant-demos-58a059b94afee29767303b399b48629985a48942.tar.gz taler-merchant-demos-58a059b94afee29767303b399b48629985a48942.tar.bz2 taler-merchant-demos-58a059b94afee29767303b399b48629985a48942.zip |
refactor base template, language selector
Diffstat (limited to 'talermerchantdemos/donations')
-rw-r--r-- | talermerchantdemos/donations/donations.py | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/talermerchantdemos/donations/donations.py b/talermerchantdemos/donations/donations.py index 85ab9ec..903952c 100644 --- a/talermerchantdemos/donations/donations.py +++ b/talermerchantdemos/donations/donations.py @@ -31,7 +31,7 @@ import traceback import urllib from taler.util.talerconfig import TalerConfig, ConfigurationError from urllib.parse import urljoin -from ..httpcommon import backend_post, backend_get, self_localized +from ..httpcommon import backend_post, backend_get, make_utility_processor import sys if not sys.version_info.major == 3 and sys.version_info.minor >= 6: @@ -89,24 +89,9 @@ def get_locale(): return "en" -## -# Extend the templating language with a function -# that fetches values from the environment. -# -# @return the environment-reading function. -@app.context_processor -def utility_processor(): - def env(name, default=None): - return os.environ.get(name, default) - - def getactive(): - return "donations" - - def getlang(): - return get_locale() - - return dict(env=env, getlang=getlang, getactive=getactive) - +# Add context processor that will make additional variables +# and functions available in the template. +app.context_processor(make_utility_processor("donations")) ## # Return a error response to the client. @@ -201,9 +186,7 @@ def index(): # @return response object of the index page. @app.route("/<lang>/") def start(lang): - return flask.render_template( - "donations-index.html.j2", merchant_currency=CURRENCY - ) + return flask.render_template("donations-index.html.j2", merchant_currency=CURRENCY) ## @@ -272,9 +255,7 @@ def donate(lang): ) order_id = order_resp["order_id"] return flask.redirect( - flask.url_for( - "fulfillment", receiver=donation_receiver, order_id=order_id - ) + flask.url_for("fulfillment", receiver=donation_receiver, order_id=order_id) ) |