# HG changeset patch # User Dennis Fink # Date 2022-01-19 20:56:06 # Node ID 81d8f0641a9cac8bfc52e3b15d43f64a0112bdab # Parent 53bbd1295ee270473e6186875bd6fad69314f6cb Reformat stuff diff --git a/c3l_membership/views.py b/c3l_membership/views.py --- a/c3l_membership/views.py +++ b/c3l_membership/views.py @@ -51,8 +51,6 @@ def index(): if form.validate_on_submit(): - xml_data = {} - if ( form.minor_member.data or form.student.data @@ -73,25 +71,6 @@ def index(): else: 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) - ) - xml_data["username"] = form.username.data - xml_data["email"] = form.email.data - xml_data["address"] = " ".join( - ( - form.street.data, - form.zip.data, - form.city.data, - form.state.data, - form.country.data, - ) - ) - xml_data["address"] = re.sub("\s+", " ", xml_data["address"]) - xml_data["voting"] = 1 if form.membership.data == "regular" else 0 - if form.payment.data in current_app.config["CRYPTOCURRENCIES"]: try: current_conversion_r = requests.get( @@ -110,12 +89,34 @@ def index(): price = price * 100 now = date.today() - year = now.year - xml_data["date"] = now + 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": " ".join( + ( + form.street.data, + form.zip.data, + form.city.data, + form.state.data, + form.country.data, + ) + ), + "address": re.sub("\s+", " ", xml_data["address"]), + "voting": 1 if form.membership.data == "regular" else 0, + "date": now, + } - xml = xml_template.format(**xml_data) html = render_template( - "member.html", form=form, price=price, year=year, xml=xml + "member.html", + form=form, + price=price, + year=now.year, + xml=xml_template.format(**xml_data), ) return render_pdf(HTML(string=html))