From 357d99cb9106398dd98a8c997ed997f97da5bf5d Mon Sep 17 00:00:00 2001 From: 3wc <3wc.cyberia@doesthisthing.work> Date: Wed, 21 Jul 2021 00:19:38 +0200 Subject: [PATCH 1/3] Add load_config_vars context processor.. ..to allow accessing config variables in the templates. This removes the need for adding config variables manually to template contexts. --- capsulflask/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/capsulflask/__init__.py b/capsulflask/__init__.py index f85f268..027ad06 100644 --- a/capsulflask/__init__.py +++ b/capsulflask/__init__.py @@ -31,7 +31,6 @@ load_dotenv(find_dotenv()) app = Flask(__name__) app.config.from_mapping( - BASE_URL=os.environ.get("BASE_URL", default="http://localhost:5000"), SECRET_KEY=os.environ.get("SECRET_KEY", default="dev"), HUB_MODE_ENABLED=os.environ.get("HUB_MODE_ENABLED", default="True").lower() in ['true', '1', 't', 'y', 'yes'], @@ -219,6 +218,9 @@ def override_url_for(): return dict(url_for=url_for_with_cache_bust) +@app.context_processor +def load_config_vars(): + return dict(config=app.config) def url_for_with_cache_bust(endpoint, **values): """ @@ -244,7 +246,3 @@ def url_for_with_cache_bust(endpoint, **values): values['q'] = current_app.config['STATIC_FILE_HASH_CACHE'][filename] return url_for(endpoint, **values) - - - - From e3a4776a5dfa470585a3730e8364ae414d813285 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.cyberia@doesthisthing.work> Date: Wed, 21 Jul 2021 00:20:38 +0200 Subject: [PATCH 2/3] Hide the BTCPay link if BTCPAY_PRIVATE_KEY un-set --- capsulflask/templates/account-balance.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/capsulflask/templates/account-balance.html b/capsulflask/templates/account-balance.html index 512e24c..de3b7b0 100644 --- a/capsulflask/templates/account-balance.html +++ b/capsulflask/templates/account-balance.html @@ -46,7 +46,9 @@ Add funds with Credit/Debit (stripe) + {% if config['BTCPAY_PRIVATE_KEY'] != "" %}
  • Add funds with Bitcoin/Litecoin/Monero (btcpay)
  • + {% endif %}
  • Cash: email treasurer@cyberia.club
  • From 7ed847251ff687620ceb995f7641a692aad96880 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.cyberia@doesthisthing.work> Date: Wed, 21 Jul 2021 00:22:58 +0200 Subject: [PATCH 3/3] Don't load /btcpay if BTCPAY_PRIVATE_KEY un-set --- capsulflask/payment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/capsulflask/payment.py b/capsulflask/payment.py index 1029f7d..b11c164 100644 --- a/capsulflask/payment.py +++ b/capsulflask/payment.py @@ -48,6 +48,10 @@ def validate_dollars(): def btcpay_payment(): errors = list() + if current_app.config['BTCPAY_PRIVATE_KEY'] == "": + flash("BTCPay is not enabled on this server") + return redirect(url_for("console.account_balance")) + if request.method == "POST": result = validate_dollars() errors = result[0] @@ -289,4 +293,4 @@ def success(): # except stripe.error.SignatureVerificationError: # print("/payment/stripe/webhook returned 400: invalid signature") # abort(400, "invalid signature") - \ No newline at end of file +