Changeset - 4eaea26f42fd
[Not reviewed]
default
3 0 4
Dennis Fink - 11 years ago 2014-02-04 01:11:55
dennis.fink@c3l.lu
moved views.py, forms.py and constants.py from root blueprint to its own subpackage
4 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ennstatus/root/__init__.py
Show inline comments
 
new file 100644
ennstatus/root/constants.py
Show inline comments
 
file renamed from ennstatus/constants.py to ennstatus/root/constants.py
ennstatus/root/forms.py
Show inline comments
 
file renamed from ennstatus/forms.py to ennstatus/root/forms.py
ennstatus/root/views.py
Show inline comments
 
file renamed from ennstatus/views.py to ennstatus/root/views.py
 
from flask import (Blueprint, render_template, current_app,
 
                   request, redirect, url_for)
 

	
 
from ennstatus.forms import BPMForm
 
from ennstatus.constants import BPM_ADDRESSES
 
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('/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')
0 comments (0 inline, 0 general)