mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 18:34:18 +00:00
First implementation of a feedback formular
This commit is contained in:
parent
fe9364e891
commit
d08014dbbe
12
app/main/forms.py
Normal file
12
app/main/forms.py
Normal 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')
|
@ -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')
|
||||
|
@ -50,7 +50,7 @@
|
||||
<span class="helper-text red-text">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="input-field ">
|
||||
<div class="input-field">
|
||||
<i class="material-icons prefix">email</i>
|
||||
{{ registration_form.email(class='validate', type='email') }}
|
||||
{{ registration_form.email.label }}
|
||||
|
35
app/templates/main/feedback.html.j2
Normal file
35
app/templates/main/feedback.html.j2
Normal 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 %}
|
Loading…
Reference in New Issue
Block a user