diff --git a/ennstatus/donate/constants.py b/ennstatus/constants.py rename from ennstatus/donate/constants.py rename to ennstatus/constants.py diff --git a/ennstatus/donate/forms.py b/ennstatus/donate/forms.py --- a/ennstatus/donate/forms.py +++ b/ennstatus/donate/forms.py @@ -3,21 +3,5 @@ from wtforms import SelectField from wtforms.validators import DataRequired -COUNTRIES = [ - ('luxembourg', 'Luxembourg'), - ('united_kingdom', 'United Kingdom'), - ('united_states', 'United States of America'), - ('belgium', 'Belgium'), - ('france', 'France'), - ('germany', 'Germany'), -] - - class DateForm(Form): date = SelectField('date', validators=[DataRequired()]) - - -class BPMForm(Form): - country = SelectField('Country', - validators=[DataRequired()], - choices=COUNTRIES) diff --git a/ennstatus/donate/views.py b/ennstatus/donate/views.py --- a/ennstatus/donate/views.py +++ b/ennstatus/donate/views.py @@ -1,9 +1,8 @@ from flask import (Blueprint, render_template, request, redirect, url_for, current_app) -from ennstatus.donate.forms import DateForm, BPMForm +from ennstatus.donate.forms import DateForm from ennstatus.donate.functions import load_csv, get_choices -from ennstatus.donate.constants import BPM_ADDRESSES donate_page = Blueprint('donate', __name__) @@ -38,36 +37,9 @@ def flattr(): return render_template('donate/flattr.html') -@donate_page.route('/bpm', methods=('GET', 'POST')) +@donate_page.route('/bpm') def bpm(): - - current_app.logger.info('Handling BPM') - 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.bpm', 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/bpm.html', form=form, - address=address) + return render_template('donate/bpm.html') @donate_page.route('/received', diff --git a/ennstatus/templates/donate/bpm.html b/ennstatus/templates/donate/bpm.html --- a/ennstatus/templates/donate/bpm.html +++ b/ennstatus/templates/donate/bpm.html @@ -13,25 +13,6 @@ Marlon Brandobrainyquote -
-
- {{ form.hidden_tag()}} -
- {{ form.country.label }} - {{ form.country(_class="form-control") }} -
- -
-
-
-
- Frënn vun der Ënn, ASBL
- BPM 381892
- {{ address['address'] }}
- {{ address['postal_code'] }},{{ address['city'] }}
- {{ address['country'] }}
-
-

We accept BPM points as they will be used for our BPM Parcel Station. The parcel station is used for receiving and sending mails and packages around the world!

Mail us your BPM voucher code! diff --git a/ennstatus/templates/root/contact.html b/ennstatus/templates/root/contact.html --- a/ennstatus/templates/root/contact.html +++ b/ennstatus/templates/root/contact.html @@ -9,13 +9,25 @@

General

+
+
+ {{ form.hidden_tag()}} +
+ {{ form.country.label }} + {{ form.country(_class="form-control") }} +
+ +
+
+
+

Please mail all general inqueries to:

Frënn vun der Ënn, ASBL
BPM 381892
- 34, Rue Gabriel Lippmann
- L-5365, Munsbach
- Luxembourg, Europe, Earth
+ {{ address['address'] }}
+ {{ address['postal_code'] }},{{ address['city'] }}
+ {{ address['country'] }}

: info@enn.lu GPG: 0x02225522
: http://enn.lu/ or http://5hwvqsndr2pv6kz.onion
diff --git a/ennstatus/views.py b/ennstatus/views.py --- a/ennstatus/views.py +++ b/ennstatus/views.py @@ -1,4 +1,8 @@ -from flask import Blueprint, render_template +from flask import (Blueprint, render_template, current_app, + request, redirect, url_for) + +from ennstatus.forms import BPMForm +from ennstatus.constants import BPM_ADDRESSES root_page = Blueprint('root', __name__) @@ -23,9 +27,35 @@ def partners(): return render_template('root/partners.html') -@root_page.route('/contact') +@root_page.route('/contact', methods=('GET', 'POST')) def contact(): - return render_template('root/contact.html') + + current_app.logger.info('Handling contact') + 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('root.contact', 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('root/contact.html', form=form, address=address) @root_page.route('/abuse')