diff --git a/c3l_membership/__init__.py b/c3l_membership/__init__.py --- a/c3l_membership/__init__.py +++ b/c3l_membership/__init__.py @@ -1,11 +1,13 @@ +import base64 import json import os.path +import secrets from flask import Flask from flask_pure import Pure from flask_qrcode import QRcode -config_file = os.path.abspath("config.json") +config_file = os.path.abspath("/etc/membership.json") pure = Pure() qrcode = QRcode() @@ -15,27 +17,8 @@ def create_app(): app = Flask(__name__) - if not hasattr(app.config, "from_json"): - - def from_json(file, silent=True): - try: - with open(file, encoding="utf-8") as json_file: - obj = json.load(json_file) - except IOError: - if silent: - return False - raise - - for key in obj: - if key.isupper(): - app.config[key] = obj[key] - - return True - - app.config.from_json = from_json - try: - app.config.from_json(config_file) + app.config.from_file(config_file, load=json.load) except FileNotFoundError: pass @@ -46,7 +29,30 @@ def create_app(): qrcode.init_app(app) - app.config["SECRET_KEY"] = "foobar" + _default_secret_key = base64.b64encode(secrets.token_bytes()).decode("utf-8") + app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", _default_secret_key) + + app.config.setdefault("SUPPORTING_FEE", 40) + app.config.setdefault("REGULAR_FEE", 120) + + app.config.setdefault("DIGICASH_ENABLED", True) + app.config.setdefault("BITCOIN_ENABLED", True) + app.config.setdefault("ETHEREUM_ENABLED", True) + app.config.setdefault("MONERO_ENABLED", True) + app.config.setdefault("ZCASH_ENABLED", True) + + app.config.setdefault( + "BITCOIN_CONVERSION_SCRIPT", "/usr/local/share/btc/BTC_Membership.pl" + ) + app.config.setdefault( + "ETHERUM_CONVERSION_SCRIPT", "/usr/local/share/eth/ETH_Membership.pl" + ) + app.config.setdefault( + "MONERO_CONVERSION_SCRIPT", "/usr/local/share/xmr/XMR_Membership.pl" + ) + app.config.setdefault( + "ZCASH_CONVERSION_SCRIPT", "/usr/local/share/zcash/ZCASH_Membership.pl" + ) from .views import root_page diff --git a/c3l_membership/forms.py b/c3l_membership/forms.py --- a/c3l_membership/forms.py +++ b/c3l_membership/forms.py @@ -1,12 +1,11 @@ from datetime import date -from flask_wtf import Form -from wtforms import BooleanField, RadioField, StringField, SubmitField -from wtforms.fields.html5 import DateField -from wtforms.validators import Email, InputRequired, Length, Optional, Required +from flask_wtf import FlaskForm +from wtforms import BooleanField, DateField, RadioField, StringField, SubmitField +from wtforms.validators import Email, InputRequired, Length, Optional -class MembershipForm(Form): +class MembershipForm(FlaskForm): username = StringField( "Username", @@ -48,13 +47,6 @@ class MembershipForm(Form): payment = RadioField( "Payment Options", validators=[InputRequired("Please select one of the options!")], - choices=[ - ("cash", "by cash"), - ("wire transfer", "by wire transfer"), - ("digicash", "by DigiCash"), - ("bitcoin", "by bitcoin"), - ("ethereum", "by ethereum"), - ], ) birthday = DateField("Birthday") @@ -96,5 +88,4 @@ class MembershipForm(Form): "I am under 18 years of age and have the approval of my legal representative." ), ) - submit = SubmitField("Become a member") diff --git a/c3l_membership/templates/index.html b/c3l_membership/templates/index.html --- a/c3l_membership/templates/index.html +++ b/c3l_membership/templates/index.html @@ -87,7 +87,7 @@
You can read more on the membership here.
The membership fee for the regular membership is 120€ per year. The membership fee for the supporting membership is 40€ per year. If you are a student, all membership fees are 40€ per year. For that please select the corresponding option.
+The membership fee for the regular membership is {{ config["REGULAR_FEE"] }}€ per year. The membership fee for the supporting membership is {{ config["SUPPORTING_FEE"] }}€ per year. If you are a student, all membership fees are {{ config["SUPPORTING_FEE"] }}€ per year. For that please select the corresponding option.
If you cannot afford the membership, please contact us via info@c3l.lu first, before filling out the membership form. We will try to find a solution together.
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 @@ -91,28 +91,53 @@