Files
@ 2cd934dc8bb9
Branch filter:
Location: FVDE/ennstatus/ennstatus/root/views.py
2cd934dc8bb9
3.0 KiB
text/x-python
Merged version_5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | from flask import (Blueprint, render_template, current_app,
request, redirect, url_for, flash)
from ennstatus.root.forms import BPMForm, MembershipForm, BridgeprogramForm
from ennstatus.root.constants import BPM_ADDRESSES
from ennstatus.root.functions import (send_membership_mail,
send_bridgeprogram_mail)
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', methods=('GET', 'POST'))
def bridgeprogram():
current_app.logger.info('Handling bridgeprogram')
form = BridgeprogramForm()
if request.method == 'POST':
current_app.logger.debug('Validation form')
if form.validate_on_submit():
send_bridgeprogram_mail(form)
return redirect(url_for('root.bridgeprogram'))
return render_template('root/bridgeprogram.html', form=form)
@root_page.route('/member')
def member():
return render_template('root/member.html')
@root_page.route('/membership', methods=('GET', 'POST'))
def membership():
current_app.logger.info('Handling membership')
form = MembershipForm()
if request.method == 'POST':
current_app.logger.debug('Validating form')
if form.validate_on_submit():
send_membership_mail(form)
return redirect(url_for('root.member'))
return render_template('root/membership.html', form=form)
@root_page.route('/mirrors')
def mirrors():
return render_template('root/mirrors.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('/ennstatus')
def ennstatus():
return render_template('root/ennstatus.html')
|