First implementation of a feedback formular

This commit is contained in:
Patrick Jentsch 2020-03-02 14:05:31 +01:00
parent fe9364e891
commit d08014dbbe
4 changed files with 62 additions and 1 deletions

12
app/main/forms.py Normal file
View File

@ -0,0 +1,12 @@
from flask_wtf import FlaskForm
from wtforms import DecimalField, StringField, SubmitField, TextAreaField
from wtforms.validators import DataRequired, Email, Length, NumberRange
class FeedbackForm(FlaskForm):
email = StringField('Email', validators=[DataRequired(), Email()])
feedback = TextAreaField('Feedback', validators=[Length(0, 255)])
like_range = DecimalField('How would you rate nopaque?',
validators=[DataRequired(),
NumberRange(min=1, max=10)])
submit = SubmitField('Send feedback')

View File

@ -1,8 +1,10 @@
from app import logger
from app.auth.forms import LoginForm from app.auth.forms import LoginForm
from app.models import User from app.models import User
from flask import flash, redirect, render_template, url_for from flask import flash, redirect, render_template, url_for
from flask_login import login_required, login_user from flask_login import login_required, login_user
from . import main from . import main
from .forms import FeedbackForm
@main.route('/', methods=['GET', 'POST']) @main.route('/', methods=['GET', 'POST'])
@ -26,6 +28,18 @@ def dashboard():
return render_template('main/dashboard.html.j2', title='Dashboard') return render_template('main/dashboard.html.j2', title='Dashboard')
@main.route('/feedback', methods=['GET', 'POST'])
@login_required
def feedback():
feedback_form = FeedbackForm(prefix='feedback-form')
if feedback_form.validate_on_submit():
logger.warning(feedback_form.email)
logger.warning(feedback_form.feedback)
logger.warning(feedback_form.like_range)
return render_template('main/feedback.html.j2',
feedback_form=feedback_form, title='Feedback')
@main.route('/poster', methods=['GET', 'POST']) @main.route('/poster', methods=['GET', 'POST'])
def poster(): def poster():
login_form = LoginForm(prefix='login-form') login_form = LoginForm(prefix='login-form')

View File

@ -50,7 +50,7 @@
<span class="helper-text red-text">{{ error }}</span> <span class="helper-text red-text">{{ error }}</span>
{% endfor %} {% endfor %}
</div> </div>
<div class="input-field "> <div class="input-field">
<i class="material-icons prefix">email</i> <i class="material-icons prefix">email</i>
{{ registration_form.email(class='validate', type='email') }} {{ registration_form.email(class='validate', type='email') }}
{{ registration_form.email.label }} {{ registration_form.email.label }}

View File

@ -0,0 +1,35 @@
{% extends "nopaque.html.j2" %}
{% block page_content %}
<div class="col s12">
<div class="card">
<form method="POST">
{{ feedback_form.hidden_tag() }}
<div class="card-content">
<p class="range-field">
{{ feedback_form.like_range.label }}
{{ feedback_form.like_range(class='validate', type='range', min=1, max=10) }}
</p>
<div class="input-field">
<i class="material-icons prefix">email</i>
{{ feedback_form.email(class='validate', type='email') }}
{{ feedback_form.email.label }}
{% for error in feedback_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">mode_edit</i>
{{ feedback_form.feedback(class='materialize-textarea', data_length='255') }}
{{ feedback_form.feedback.label }}
</div>
</div>
<div class="card-action right-align">
{{ macros.submit_button(feedback_form.submit) }}
</div>
</form>
</div>
</div>
{% endblock %}