Changeset - 53bbd1295ee2
[Not reviewed]
default
0 2 0
Dennis Fink - 3 years ago 2022-01-19 20:50:54
dennis.fink@c3l.lu
Show an error message to the user, if we fail fetching conversion rates for the cryptocurrencies
2 files changed with 9 insertions and 7 deletions:
0 comments (0 inline, 0 general)
c3l_membership/templates/index.html
Show inline comments
 
@@ -47,6 +47,9 @@
 
            {% endfor %}
 
          {% endfor %}
 
        {% endif %}
 
        {% if crypto_error %}
 
          <p class="form-error">{% trans %}Couldn't fetch conversion rate for cryptocurrencies. Please try again later or use another payment option!{% endtrans %}</p>
 
        {% endif %}
 
        <form class="pure-form pure-form-stacked" method="POST" action="{{ url_for('root.index', lang_code=g.lang_code) }}">
 
          <fieldset>
 
            {{ form.hidden_tag() }}
c3l_membership/views.py
Show inline comments
 
@@ -58,7 +58,6 @@ def index():
 
            or form.student.data
 
            or form.membership.data == "supporting"
 
        ):
 

	
 
            price = current_app.config["SUPPORTING_FEE"]
 
        elif form.starving.data:
 
            price = 1
 
@@ -94,14 +93,13 @@ def index():
 
        xml_data["voting"] = 1 if form.membership.data == "regular" else 0
 

	
 
        if form.payment.data in current_app.config["CRYPTOCURRENCIES"]:
 

	
 
            current_conversion_r = requests.get(
 
                current_app.config["CONVERSION_URL"], timeout=30
 
            )
 
            try:
 
                current_conversion_r = requests.get(
 
                    current_app.config["CONVERSION_URL"], timeout=30
 
                )
 
                current_conversion_r.raise_for_status()
 
            except:
 
                return 500
 
                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][
 
@@ -120,4 +118,5 @@ def index():
 
            "member.html", form=form, price=price, year=year, xml=xml
 
        )
 
        return render_pdf(HTML(string=html))
 
    return render_template("index.html", form=form)
 

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