diff --git a/c3l_membership/templates/member.html b/c3l_membership/templates/member.html
--- a/c3l_membership/templates/member.html
+++ b/c3l_membership/templates/member.html
@@ -65,7 +65,7 @@
{% trans %}Payment:{% endtrans %}
-
{{ form.payment.data }}
+
{{ form.payment.data.lower() }}
{% trans %}Agreed to Terms & Conditions:{% endtrans %}
@@ -97,7 +97,8 @@
{% trans %}Amount:{% endtrans %} {{ price }} {{ config["CRYPTOCURRENCIES"][form.payment.data]["COMMODITY"] }}
- {% set crypto_url=config["CRYPTOCURRENCIES"][form.payment.data]["URL"].format(amount=price, year=year, username=form.username.data) %}
+ {% set address = config["CRYPTOCURRENCIES"][form.payment.data]["ADDRESS"] %}
+ {% set crypto_url=config["CRYPTOCURRENCIES"][form.payment.data]["URL"].format(address=address, amount=price, year=year, username=form.username.data) %}
{% elif form.payment.data == 'digicash' %}
diff --git a/c3l_membership/views.py b/c3l_membership/views.py
--- a/c3l_membership/views.py
+++ b/c3l_membership/views.py
@@ -2,6 +2,7 @@ import re
import subprocess
from datetime import date
+import requests
from flask import Blueprint, current_app, g, render_template, request
from flask_babel import gettext
from flask_weasyprint import HTML, render_pdf
@@ -42,7 +43,7 @@ def index():
choices.append(
(
cryptocurrency_label,
- " ".format((gettext("by"), options)),
+ " ".join((gettext("by"), cryptocurrency_label.title())),
),
)
@@ -65,14 +66,15 @@ def index():
if form.starving.data:
price = 1
- xml_data["status"] = "Starving"
+ status = "Starving"
elif form.minor_member.data or form.student.data:
- xml_data["status"] = "Student"
+ status = "Student"
elif form.membership.data == "supporting":
- xml_data["status"] = "Supporter"
+ status = "Supporter"
else:
- xml_data["status"] = "Regular"
+ status = "Regular"
+ xml_data["status"] = status
xml_data["name"] = form.fullname.data
xml_data["birthday"] = (
form.birthday.data if form.birthday.data is not None else date(9999, 12, 12)
@@ -91,15 +93,20 @@ def index():
xml_data["address"] = re.sub("\s+", " ", xml_data["address"])
if form.payment.data in current_app.config["CRYPTOCURRENCIES"]:
- price = subprocess.run(
- [
- current_app.config["CRYPTOCURRENCIES_CONVERSION_SCRIPT"],
- str(price),
- form.payment.data,
- ],
- capture_output=True,
- encoding="utf-8",
- ).stdout
+
+ current_conversion_r = requests.get(
+ current_app.config["CONVERSION_URL"], timeout=30
+ )
+ try:
+ current_conversion_r.raise_for_status()
+ except:
+ return 500
+ else:
+ current_conversion = current_conversion_r.json()
+ commodity = current_app.config["CRYPTOCURRENCIES"][form.payment.data][
+ "COMMODITY"
+ ]
+ price = current_conversion[commodity][status.upper()]
elif form.payment.data == "digicash":
price = price * 100
diff --git a/poetry.lock b/poetry.lock
--- a/poetry.lock
+++ b/poetry.lock
@@ -72,6 +72,14 @@ doc = ["sphinx", "sphinx-rtd-theme"]
test = ["pytest-runner", "pytest-cov", "pytest-flake8", "pytest-isort"]
[[package]]
+name = "certifi"
+version = "2021.10.8"
+description = "Python package for providing Mozilla's CA Bundle."
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
name = "cffi"
version = "1.15.0"
description = "Foreign Function Interface for Python calling C code."
@@ -83,6 +91,17 @@ python-versions = "*"
pycparser = "*"
[[package]]
+name = "charset-normalizer"
+version = "2.0.10"
+description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
+category = "main"
+optional = false
+python-versions = ">=3.5.0"
+
+[package.extras]
+unicode_backport = ["unicodedata2"]
+
+[[package]]
name = "click"
version = "8.0.3"
description = "Composable command line interface toolkit"
@@ -428,6 +447,24 @@ pil = ["pillow"]
test = ["pytest", "pytest-cov"]
[[package]]
+name = "requests"
+version = "2.27.1"
+description = "Python HTTP for Humans."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
+
+[package.dependencies]
+certifi = ">=2017.4.17"
+charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""}
+idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""}
+urllib3 = ">=1.21.1,<1.27"
+
+[package.extras]
+socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
+use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"]
+
+[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
@@ -475,6 +512,19 @@ optional = false
python-versions = ">=3.6"
[[package]]
+name = "urllib3"
+version = "1.26.8"
+description = "HTTP library with thread-safe connection pooling, file post, and more."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+
+[package.extras]
+brotli = ["brotlipy (>=0.6.0)"]
+secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
+socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
+
+[[package]]
name = "weasyprint"
version = "52.5"
description = "The Awesome Document Factory"
@@ -544,7 +594,7 @@ testing = ["pytest (>=4.6)", "pytest-che
[metadata]
lock-version = "1.1"
python-versions = ">=3.7.0,<4"
-content-hash = "e6337b7e5ae01abe852dbd202497fef50c09546e0a0f98f26b3ee81beb262237"
+content-hash = "09986a21dfa3c1e41f48db17b04f4f3bade80e86642fecd895ad3df4b9cf061e"
[metadata.files]
babel = [
@@ -562,6 +612,10 @@ cairosvg = [
{file = "CairoSVG-2.5.2-py3-none-any.whl", hash = "sha256:98c276b7e4f0caf01e5c7176765c104ffa1aa1461d63b2053b04ab663cf7052b"},
{file = "CairoSVG-2.5.2.tar.gz", hash = "sha256:b0b9929cf5dba005178d746a8036fcf0025550f498ca54db61873322384783bc"},
]
+certifi = [
+ {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"},
+ {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"},
+]
cffi = [
{file = "cffi-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:c2502a1a03b6312837279c8c1bd3ebedf6c12c4228ddbad40912d671ccc8a962"},
{file = "cffi-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:23cfe892bd5dd8941608f93348c0737e369e51c100d03718f108bf1add7bd6d0"},
@@ -614,6 +668,10 @@ cffi = [
{file = "cffi-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:3773c4d81e6e818df2efbc7dd77325ca0dcb688116050fb2b3011218eda36139"},
{file = "cffi-1.15.0.tar.gz", hash = "sha256:920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954"},
]
+charset-normalizer = [
+ {file = "charset-normalizer-2.0.10.tar.gz", hash = "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd"},
+ {file = "charset_normalizer-2.0.10-py3-none-any.whl", hash = "sha256:cb957888737fc0bbcd78e3df769addb41fd1ff8cf950dc9e7ad7793f1bf44455"},
+]
click = [
{file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"},
{file = "click-8.0.3.tar.gz", hash = "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"},
@@ -847,6 +905,10 @@ pytz = [
qrcode = [
{file = "qrcode-7.3.1.tar.gz", hash = "sha256:375a6ff240ca9bd41adc070428b5dfc1dcfbb0f2507f1ac848f6cded38956578"},
]
+requests = [
+ {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"},
+ {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"},
+]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
@@ -884,6 +946,10 @@ typing-extensions = [
{file = "typing_extensions-4.0.1-py3-none-any.whl", hash = "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"},
{file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"},
]
+urllib3 = [
+ {file = "urllib3-1.26.8-py2.py3-none-any.whl", hash = "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed"},
+ {file = "urllib3-1.26.8.tar.gz", hash = "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"},
+]
weasyprint = [
{file = "WeasyPrint-52.5-py3-none-any.whl", hash = "sha256:3433d657049a65d7d63f545fd71f5efa8aae7f05d24e49e01a757973fd3799f1"},
{file = "WeasyPrint-52.5.tar.gz", hash = "sha256:b37ea02d75ca04babd7becad7341426be332ae560d8f02d664bfa1e9afb18481"},
diff --git a/pyproject.toml b/pyproject.toml
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,6 +17,7 @@ WTForms="^3.0.1"
WeasyPrint="52.5"
djhtml = "^1.4.11"
Flask-Babel = "^2.0.0"
+requests = "^2.27.1"
[tool.poetry.dev-dependencies]
black = "^21.12b0"