Esempio n. 1
0
def feedback_form(username):
    """Show form to add feedback"""

    if "username" not in session or username != session['username']:
        raise Unauthorized()

    form = FeedbackForm()

    if form.validate_on_submit():
        new_feedback = {
            'title': form.title.data,
            'content': form.content.data,
            'username': username
        }
        Feedback.add_new_feedback(new_feedback)

        return redirect(f"/users/{username}")

    else:
        return render_template("/feedback/feedback.html",
                               form=form,
                               user=username)