Changeset - a65e79a6c323
[Not reviewed]
default
0 1 0
Dennis Fink - 3 years ago 2022-05-10 23:36:24
dennis.fink@c3l.lu
Automatically download PDF
1 file changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
c3l_membership/views.py
Show inline comments
 
@@ -87,51 +87,54 @@ def index():
 
                    current_app.config["CONVERSION_URL"], timeout=30
 
                )
 
                current_conversion_r.raise_for_status()
 
            except:
 
                return render_template("index.html", form=form, crypto_error=True), 503
 
            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 in ("digicash", "satispay"):
 
            price = price * 100
 

	
 
        today = date.today()
 
        xml_data = {
 
            "status": status,
 
            "name": form.fullname.data,
 
            "birthday": form.birthday.data
 
            if form.birthday.data is not None
 
            else date(9999, 12, 12),
 
            "username": form.username.data,
 
            "email": form.email.data,
 
            "address": re.sub(
 
                "\s+",
 
                " ",
 
                " ".join(
 
                    (
 
                        form.street.data,
 
                        form.zip.data,
 
                        form.city.data,
 
                        form.state.data,
 
                        form.country.data,
 
                    )
 
                ),
 
            ),
 
            "voting": 1 if form.membership.data == "regular" else 0,
 
            "date": today,
 
        }
 

	
 
        html = render_template(
 
            "member.html",
 
            form=form,
 
            price=price,
 
            year=today.year,
 
            voting=True if form.membership.data == "regular" else False,
 
            xml=xml_template.format(**xml_data),
 
        )
 
        return render_pdf(HTML(string=html))
 
        return render_pdf(
 
            HTML(string=html),
 
            download_filename=f"C3L_Membership_{form.username.data}.pdf",
 
        )
 

	
 
    return render_template("index.html", form=form, crypto_error=False)
0 comments (0 inline, 0 general)