diff --git a/app/main/forms.py b/app/main/forms.py new file mode 100644 index 00000000..d209a6ba --- /dev/null +++ b/app/main/forms.py @@ -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') diff --git a/app/main/views.py b/app/main/views.py index 65f02548..8f855399 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -1,8 +1,10 @@ +from app import logger from app.auth.forms import LoginForm from app.models import User from flask import flash, redirect, render_template, url_for from flask_login import login_required, login_user from . import main +from .forms import FeedbackForm @main.route('/', methods=['GET', 'POST']) @@ -26,6 +28,18 @@ def 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']) def poster(): login_form = LoginForm(prefix='login-form') diff --git a/app/templates/auth/login.html.j2 b/app/templates/auth/login.html.j2 index ce6ab69f..6f57d209 100644 --- a/app/templates/auth/login.html.j2 +++ b/app/templates/auth/login.html.j2 @@ -26,8 +26,8 @@