# HG changeset patch # User Dennis Fink # Date 2015-02-16 02:29:06 # Node ID 32f836e7ff5d37ee5773fca7b96cb6597dd533ac # Parent 75d382be0f33b55db12e3f7c71405f378c10b17c Get more feedback to the user diff --git a/ennstatus/root/forms.py b/ennstatus/root/forms.py --- a/ennstatus/root/forms.py +++ b/ennstatus/root/forms.py @@ -1,6 +1,6 @@ from flask_wtf import Form from wtforms import SelectField, StringField, RadioField, BooleanField, SubmitField -from wtforms.validators import DataRequired, InputRequired, Email, Optional, Length +from wtforms.validators import InputRequired, Email, Length, DataRequired @@ -24,7 +24,9 @@ class MembershipForm(Form): username = StringField('Username*', validators=[ - InputRequired('This field is required!')] + InputRequired('This field is required!'), + Length(max=255) + ] ) email = StringField('E-Mail*', validators=[ @@ -33,29 +35,29 @@ class MembershipForm(Form): ] ) firstname = StringField('First Name', - validators=[Optional()], + validators=[Length(max=255)], ) surname = StringField('Surname', - validators=[Optional()], + validators=[Length(max=255)], ) street = StringField('Nr., Street', - validators=[Optional()], + validators=[Length(max=4000)], ) zip = StringField('ZIP-Code', - validators=[Length(max=30), Optional()], + validators=[Length(max=30)], ) city = StringField('City/Town', - validators=[Optional()], + validators=[Length(max=500)], ) country = StringField('Country', - validators=[Optional()], + validators=[Length(max=500)], ) gpg = StringField('GPG-ID', - validators=[Optional()], + validators=[Length(max=18)], ) membership = RadioField('Membership Plan*', - validators=[DataRequired()], + validators=[InputRequired('Please select one of the options!')], choices=[ ('regular', 'Regular membership (120€/year)'), ('student', 'Student membership (60€/year)'), diff --git a/ennstatus/root/views.py b/ennstatus/root/views.py --- a/ennstatus/root/views.py +++ b/ennstatus/root/views.py @@ -1,5 +1,5 @@ from flask import (Blueprint, render_template, current_app, - request, redirect, url_for) + request, redirect, url_for, flash) from ennstatus.root.forms import BPMForm, MembershipForm from ennstatus.root.constants import BPM_ADDRESSES diff --git a/ennstatus/templates/root/membership.html b/ennstatus/templates/root/membership.html --- a/ennstatus/templates/root/membership.html +++ b/ennstatus/templates/root/membership.html @@ -9,61 +9,16 @@

Register as member

{{ form.hidden_tag() }} -
- {{ form.username.label(class_='control-label col-lg-2') }} -
- {{ form.username(class_='form-control') }} -
-
-
- {{ form.email.label(class_='control-label col-lg-2') }} -
- {{ form.email(class_='form-control') }} -
-
-
- {{ form.firstname.label(class_='control-label col-lg-2') }} -
- {{ form.firstname(class_='form-control') }} -
-
-
- {{ form.surname.label(class_='control-label col-lg-2') }} -
- {{ form.surname(class_='form-control') }} -
-
-
- {{ form.street.label(class_='control-label col-lg-2') }} -
- {{ form.street(class_='form-control') }} -
-
-
- {{ form.zip.label(class_='control-label col-lg-2') }} -
- {{ form.zip(class_='form-control') }} -
-
-
- {{ form.city.label(class_='control-label col-lg-2') }} -
- {{ form.city(class_='form-control') }} -
-
-
- {{ form.country.label(class_='control-label col-lg-2') }} -
- {{ form.country(class_='form-control') }} -
-
-
- {{ form.gpg.label(class_='control-label col-lg-2') }} -
- {{ form.gpg(class_='form-control') }} -
-
-
+ {{ wtf.form_field(form.username, form_type='horizontal') }} + {{ wtf.form_field(form.email, form_type='horizontal') }} + {{ wtf.form_field(form.firstname, form_type='horizontal') }} + {{ wtf.form_field(form.surname, form_type='horizontal') }} + {{ wtf.form_field(form.street, form_type='horizontal') }} + {{ wtf.form_field(form.city, form_type='horizontal') }} + {{ wtf.form_field(form.zip, form_type='horizontal') }} + {{ wtf.form_field(form.country, form_type='horizontal') }} + {{ wtf.form_field(form.gpg, form_type='horizontal') }} +
{{ form.membership.label(class_='control-label col-lg-2') }}
{% for field in form.membership %} @@ -74,9 +29,16 @@
{% endfor %}
+ {% if form.membership.errors %} +
+ {% for error in form.membership.errors %} +

{{ error }}

+ {% endfor %} +
+ {% endif %}
- +