Exemplo n.º 1
0
def comments_create():

    form = CommentForm(request.form)
    threadi = Thread.query.get(form.thread_id.data)

    if not form.validate():
        return redirect(url_for("show_thread", thread_id=threadi.id))

    comm = Comment(form.message.data)
    comm.account_id = current_user.id
    comm.thread_id = form.thread_id.data

    db.session().add(comm)
    db.session().commit()

    return redirect(url_for("show_thread", thread_id=threadi.id))
Exemplo n.º 2
0
def comment_post(thread_id):
    form = CommentForm(request.form)
    
    if not form.validate():
        thread = Thread.query.get(thread_id)
        comments = thread.comments
        
        return render_template("threads/showthread.html", form = form, comments = comments, thread = thread, user = thread.user)

    comment = Comment(form.comment.data)
    comment.thread_id = thread_id
    comment.user_id = current_user.id
    db.session().add(comment)
    db.session().commit()

    return threadviews.threads_open(thread_id)