Files
@ 6f1bbcc4fab1
Branch filter:
Location: C3L/C3L-Membership-Online-Form/c3l_membership/views.py - annotation
6f1bbcc4fab1
1.4 KiB
text/x-python
Added .hgignore
6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 6f06fc328a13 | import subprocess
from datetime import date
from flask import Blueprint, current_app, render_template, request
from flask_weasyprint import HTML, render_pdf
from .forms import MembershipForm
root_page = Blueprint("root", __name__)
@root_page.route("/", methods=("GET", "POST"))
def index():
form = MembershipForm()
if form.validate_on_submit():
if form.minor_member.data and form.membership.data != "starving":
membership = "student"
else:
membership = form.membership.data
if membership in ["student", "supporting"]:
price = 40
elif membership == "starving":
price = 1
else:
price = 120
if form.payment.data == "bitcoin":
price = subprocess.check_output(
["/usr/local/share/btc/BTC_Membership.pl", str(price)]
).decode("utf-8")
elif form.payment.data == "ethereum":
price = subprocess.check_output(
["/usr/local/share/eth/ETH_Membership.pl", str(price)]
).decode("utf-8")
elif form.payment.data == "digicash":
price = price * 100
year = date.today().year
html = render_template(
"member.html", form=form, membership=membership, price=price, year=year
)
return render_pdf(HTML(string=html))
return render_template("index.html", form=form)
|