Re-combine index handlers
This commit is contained in:
parent
7c8fec11e7
commit
5803efd4bb
1 changed files with 15 additions and 26 deletions
|
@ -7,9 +7,22 @@ from .utils import getTemps, avg_air_temp, ann_air_indices, \
|
||||||
from .models import DB
|
from .models import DB
|
||||||
|
|
||||||
|
|
||||||
@main.route('/', methods=['GET'])
|
@main.route('/', methods=['GET', 'POST'])
|
||||||
def index():
|
def index():
|
||||||
form = generateForm()
|
form = AKIForm()
|
||||||
|
form.community.choices = communitiesSelect()
|
||||||
|
form.dataset.choices = datasetsSelect()
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
session['community'] = request.form['community']
|
||||||
|
session['minyear'] = request.form['minyear']
|
||||||
|
session['maxyear'] = request.form['maxyear']
|
||||||
|
if session['minyear'] > session['maxyear']:
|
||||||
|
session['maxyear'] = session['minyear']
|
||||||
|
|
||||||
|
session['datasets'] = request.form['dataset']
|
||||||
|
return redirect(url_for('main.index'))
|
||||||
|
|
||||||
session['community_data'] = None
|
session['community_data'] = None
|
||||||
session['avg_temp'] = None
|
session['avg_temp'] = None
|
||||||
session['avg_indices'] = None
|
session['avg_indices'] = None
|
||||||
|
@ -39,23 +52,6 @@ def index():
|
||||||
return render_template('main/index.html', form=form)
|
return render_template('main/index.html', form=form)
|
||||||
|
|
||||||
|
|
||||||
@main.route('/', methods=['POST'])
|
|
||||||
def index_submit():
|
|
||||||
form = generateForm()
|
|
||||||
if form.validate():
|
|
||||||
session['community'] = request.form['community']
|
|
||||||
session['minyear'] = request.form['minyear']
|
|
||||||
session['maxyear'] = request.form['maxyear']
|
|
||||||
if session['minyear'] > session['maxyear']:
|
|
||||||
session['maxyear'] = session['minyear']
|
|
||||||
|
|
||||||
session['datasets'] = request.form['dataset']
|
|
||||||
return redirect(url_for('main.index'))
|
|
||||||
else:
|
|
||||||
# TODO: Fix post-POST handling
|
|
||||||
return render_template('main/index.html', form=form)
|
|
||||||
|
|
||||||
|
|
||||||
@main.route('/datatypes')
|
@main.route('/datatypes')
|
||||||
def datatypes():
|
def datatypes():
|
||||||
return render_template('main/datatypes.html')
|
return render_template('main/datatypes.html')
|
||||||
|
@ -111,10 +107,3 @@ def delete():
|
||||||
record = request.args.get('record', '')
|
record = request.args.get('record', '')
|
||||||
session['save'].pop(record)
|
session['save'].pop(record)
|
||||||
return redirect(url_for('main.index'))
|
return redirect(url_for('main.index'))
|
||||||
|
|
||||||
|
|
||||||
def generateForm():
|
|
||||||
form = AKIForm()
|
|
||||||
form.community.choices = communitiesSelect()
|
|
||||||
form.dataset.choices = datasetsSelect()
|
|
||||||
return form
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue