Changeset - 05866e023ce5
[Not reviewed]
version_5
0 3 0
Dennis Fink - 10 years ago 2015-07-21 18:15:21
dennis.fink@c3l.lu
Fixed dynamic address form
3 files changed with 4 insertions and 8 deletions:
0 comments (0 inline, 0 general)
ennstatus/donate/views.py
Show inline comments
 
@@ -20,27 +20,26 @@ def wiretransfer():
 
    return render_template('donate/wiretransfer.html')
 

	
 

	
 
@donate_page.route('/snailmail', methods=('GET', 'POST'))
 
def snailmail():
 

	
 
    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))
 
        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'
 

	
ennstatus/root/forms.py
Show inline comments
 
from flask_wtf import Form
 
from wtforms import SelectField, StringField, RadioField, BooleanField, SubmitField
 
from wtforms.validators import InputRequired, Email, Length, DataRequired
 

	
 

	
 

	
 
COUNTRIES = [
 
    ('luxembourg', 'Luxembourg'),
 
    ('united_kingdom', 'United Kingdom'),
 
    ('united_states', 'United States of America'),
 
    ('belgium', 'Belgium'),
 
    ('france', 'France'),
 
    ('germany', 'Germany'),
 
]
 

	
 

	
 
class BPMForm(Form):
 
    country = SelectField('Country',
 
                          validators=[DataRequired()],
 
                          choices=COUNTRIES)
 

	
 

	
 
class MembershipForm(Form):
 

	
 
    username = StringField('Username*',
 
                           validators=[
 
                               InputRequired('This field is required!'),
 
                               Length(max=255)
 
                           ]
 
                           )
 
    email = StringField('E-Mail*',
ennstatus/root/views.py
Show inline comments
 
@@ -53,27 +53,26 @@ def membership():
 
    return render_template('root/membership.html', form=form)
 

	
 

	
 
@root_page.route('/contact', methods=('GET', 'POST'))
 
def contact():
 

	
 
    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))
 
        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'
 

	
0 comments (0 inline, 0 general)