Files @ 7f9dc38d8318
Branch filter:

Location: FVDE/ennstatus/ennstatus/root/views.py

Dennis Fink
Added preliminary support for .bit addresses
from flask import (Blueprint, render_template, current_app,
                   request, redirect, url_for)

from ennstatus.root.forms import BPMForm
from ennstatus.root.constants import BPM_ADDRESSES

root_page = Blueprint('root', __name__)


@root_page.route('/')
def index():
    return render_template('root/index.html')


@root_page.route('/about')
def about():
    return render_template('root/about.html')


@root_page.route('/services')
def services():
    return render_template('root/services.html')


@root_page.route('/partners')
def partners():
    return render_template('root/partners.html')


@root_page.route('/bridgeprogram')
def bridgeprogram():
    return render_template('root/bridgeprogram.html')


@root_page.route('/member')
def member():
    return render_template('root/member.html')


@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))
    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')
def abuse():
    return render_template('root/abuse.html')


@root_page.route('/disclaimer')
def disclaimer():
    return render_template('root/disclaimer.html')