Add dataset selection with validation
This commit is contained in:
parent
e83f7a0271
commit
bec6b19d1c
|
@ -6,3 +6,5 @@ from flask_bootstrap import Bootstrap
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = SECRET_KEY
|
app.secret_key = SECRET_KEY
|
||||||
bootstrap = Bootstrap(app)
|
bootstrap = Bootstrap(app)
|
||||||
|
|
||||||
|
from app import errors, routes
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
from constants import DATASETS
|
||||||
|
from flask_wtf import FlaskForm
|
||||||
|
from wtforms import SelectField, SubmitField
|
||||||
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
|
||||||
|
class DatasetForm(FlaskForm):
|
||||||
|
dataset = SelectField(validators=[DataRequired()], choices=DATASETS)
|
||||||
|
submit = SubmitField("Submit")
|
|
@ -1,6 +1,7 @@
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
|
|
||||||
from app import app
|
from app import app
|
||||||
|
from app.forms import DatasetForm
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
|
@ -11,4 +12,12 @@ def index():
|
||||||
|
|
||||||
@app.route("/data")
|
@app.route("/data")
|
||||||
def data():
|
def data():
|
||||||
return render_template("data.html", title="Data")
|
form = DatasetForm()
|
||||||
|
if form.validate_on_submit():
|
||||||
|
return render_template("visualization.html", form=form, title="Visualization")
|
||||||
|
return render_template("data.html", title="Data", form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/visualization")
|
||||||
|
def visualization():
|
||||||
|
return render_template("visualization.html", title="Visualization", form=form)
|
||||||
|
|
|
@ -29,14 +29,6 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{% with messages = get_flashed_messages() %}
|
|
||||||
{% if messages %}
|
|
||||||
{% for message in messages %}
|
|
||||||
<div class="alert alert-info" role="alert">{{ message }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
{# application content needs to be provided in the app_content block #}
|
{# application content needs to be provided in the app_content block #}
|
||||||
{% block app_content %}{% endblock %}
|
{% block app_content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% import 'bootstrap/wtf.html' as wtf %}
|
||||||
|
|
||||||
{% block content %}
|
{% block app_content %}
|
||||||
<h1 class="text-center">How you like your data?</h1>
|
<h1>Select a dataset</h1>
|
||||||
<li>
|
<div class="row">
|
||||||
<p class="text-center">
|
<div class="col-md-4">
|
||||||
<a href="{{ url_for('map_view') }}" class="btn btn-success" role="button" aria-pressed="true">Maps</a>
|
{{ wtf.quick_form(form) }}
|
||||||
</p>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
<li>
|
<br>
|
||||||
<p class="text-center">
|
|
||||||
<a href="{{ url_for('plot_view') }}" class="btn btn-success" role="button" aria-pressed="true">Plots</a>
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue