diff --git a/ennstatus/donate/views.py b/ennstatus/donate/views.py --- a/ennstatus/donate/views.py +++ b/ennstatus/donate/views.py @@ -29,8 +29,9 @@ def snailmail(): if request.method == 'POST': current_app.logger.debug('Validating form') - country = form.country.data - return redirect(url_for('donate.snailmail', country=country)) + 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'] diff --git a/ennstatus/root/forms.py b/ennstatus/root/forms.py --- a/ennstatus/root/forms.py +++ b/ennstatus/root/forms.py @@ -3,6 +3,7 @@ from wtforms import SelectField, StringF from wtforms.validators import InputRequired, Email, Length, DataRequired + COUNTRIES = [ ('luxembourg', 'Luxembourg'), ('united_kingdom', 'United Kingdom'), @@ -15,6 +16,7 @@ COUNTRIES = [ class BPMForm(Form): country = SelectField('Country', + validators=[DataRequired()], choices=COUNTRIES) diff --git a/ennstatus/root/views.py b/ennstatus/root/views.py --- a/ennstatus/root/views.py +++ b/ennstatus/root/views.py @@ -62,8 +62,9 @@ def contact(): if request.method == 'POST': current_app.logger.debug('Validating form') - country = form.country.data - return redirect(url_for('root.contact', country=country)) + 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']