diff --git a/ennstatus/donate/views.py b/ennstatus/donate/views.py --- a/ennstatus/donate/views.py +++ b/ennstatus/donate/views.py @@ -4,6 +4,9 @@ from flask import (Blueprint, render_tem from ennstatus.donate.forms import DateForm from ennstatus.donate.functions import load_csv, get_choices +from ennstatus.root.forms import BPMForm +from ennstatus.root.constants import BPM_ADDRESSES + donate_page = Blueprint('donate', __name__) @@ -17,9 +20,34 @@ def wiretransfer(): return render_template('donate/wiretransfer.html') -@donate_page.route('/snailmail') +@donate_page.route('/snailmail', methods=('GET', 'POST')) def snailmail(): - return render_template('donate/snailmail.html') + + current_app.logger.info('Handling snailmail') + form = BPMForm() + country_choices = [choice[0] for choice in form.country.choices] + + if request.method == 'POST': + current_app.logger.debug('Validating form') + if form.validate_on_submit(): + country = form.country.data + return redirect(url_for('donate.snailmail', country=country)) + else: + if 'country' in request.args: + country = request.args['country'] + if country in country_choices: + current_app.logger.info('Showing country %s' % country) + else: + current_app.logger.warn('Country %s not found' % country) + country = 'luxembourg' + else: + current_app.logger.info('Using default country') + country = 'luxembourg' + + form.country.data = country + address = BPM_ADDRESSES[country] + + return render_template('donate/snailmail.html', form=form, address=address) @donate_page.route('/paypal') diff --git a/ennstatus/templates/donate/snailmail.html b/ennstatus/templates/donate/snailmail.html --- a/ennstatus/templates/donate/snailmail.html +++ b/ennstatus/templates/donate/snailmail.html @@ -13,6 +13,18 @@ Paco Ahlgren +
+
+ {{ form.hidden_tag() }} +
+ {{ form.country.label }} + {{ form.country(_class="form-control") }} +
+ +
+
+
+

SnailMail is most probably, the most anonymous way to support us - as long as you debit / change the money anonymously and touch it without your fingerprints.