Skip to content

Commit

Permalink
Remove demo form from index page
Browse files Browse the repository at this point in the history
  • Loading branch information
jftsang committed Feb 21, 2022
1 parent 84a3c21 commit 29eca96
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 99 deletions.
8 changes: 0 additions & 8 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ def __call__(self, form, field):
raise StopValidation(f'The CSV is expected to have the field names {feasts_fields}')


class MyForm(FlaskForm):
name = StringField('name', validators=[DataRequired()])
selectable_one = SelectField('selectable one', choices=['Foo', 'Bar', 'Baz'])
selectable_two = SelectField('selectable two', choices=['Foo', 'Bar', 'Baz'])
radio = RadioField('radio', choices=[(1, 'option 1'), (2, 'option 2')],
validators=[DataRequired()])


class PewSheetForm(FlaskForm):
feast_names = [feast.name for feast in Feast.all()]
title = StringField('Title', validators=[DataRequired()])
Expand Down
86 changes: 3 additions & 83 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,91 +1,11 @@
{% extends 'base.html' %}
{% block title %}PyPew{% endblock %}
{% block content %}

<h1>Welcome to PyPew</h1>

<p>PyPew is a pew sheet generator.</p>

<p>The form that you see on this page is just for UI experimental purposes.
Please turn your attention to the Feasts or Pew Sheet views: look up
about three centimetres.</p>



<h1>Example form</h1>

<p>This is an example of what a form would look like.</p>
<div class="container">
<form method="post" action="/">
{{ form.csrf_token }}

<div class="row mb-3">
{{ form.name.label(class='col-sm-1 col-form-label') }}
<div class="col-sm-5">
{{ form.name(class='form-control') }}
{% if form.name.errors %}
{% for error in form.name.errors %}
<small class="font-small text-danger">
{{ error }}
</small>
{% endfor %}
{% endif %}
</div>
</div>

<div class="row mb-3">
{{ form.selectable_one.label(class='col-sm-1 col-form-label') }}
<div class="col-sm-3">
{{ form.selectable_one(class='form-select') }}
{% if form.selectable_one.errors %}
{% for error in form.selectable_one.errors %}
<small class="font-small text-danger">
{{ error }}
</small>
{% endfor %}
{% endif %}
</div>

{{ form.selectable_two.label(class='col-sm-1 col-form-label') }}
<div class="col-sm-3">
{{ form.selectable_two(class='form-select') }}
{% if form.selectable_two.errors %}
{% for error in form.selectable_two.errors %}
<small class="font-small text-danger">
{{ error }}
</small>
{% endfor %}
{% endif %}
</div>
</div>

<div class="row mb-3">
{{ form.radio.label(class='col-sm-1 col-form-label') }}
<div class="col-sm-5 row">
{# {{ form.radio(class='form-radio-input') }}#}
{% for option in form.radio %}
<div class="col-auto">
{{ option }}
{{ option.label }}
</div>
{% endfor %}
{% if form.radio.errors %}
{% for error in form.radio.errors %}
<small class="font-small text-danger">
{{ error }}
</small>
{% endfor %}
{% endif %}
</div>
</div>


<div class="row">
<div class="col-sm-4"></div>
<div class="col-auto">
<input type="submit" class="btn btn-secondary w-100" value="Go">
</div>
</div>
</form>
</div>
<p>Please turn your attention to the <a class="link link-info" href="{{ url_for('feast_index_view') }}">
list of feasts</a>, or <a class="link-info" href="{{ url_for('pew_sheet_create_view') }}">
create a service</a>.</p>
{% endblock %}
10 changes: 2 additions & 8 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
render_template, flash, send_file, redirect, url_for, make_response
)

from forms import MyForm, PewSheetForm, UpdateTextsForm
from forms import PewSheetForm, UpdateTextsForm
from models import Feast, PewSheet, NotFoundError, get
from utils import logger

TEXTS_CSV = os.path.join(os.path.dirname(__file__), 'data', 'feasts.csv')


def index_view():
form = MyForm()
if form.validate_on_submit():
flash(f"Hello, {form.name.data}, you selected "
f"{form.selectable_one.data} and {form.selectable_two.data} "
f"and option {form.radio.data}")

return render_template('index.html', nav_active='Home', form=form)
return render_template('index.html', nav_active='Home')


def feast_index_view():
Expand Down

0 comments on commit 29eca96

Please sign in to comment.