Пример #1
0
def add_comment(index):
    content = request.form.get('comment_content')
    comment = Comment(content=content)
    comment.user_id = g.user.id
    comment.article_id = index
    # comment.reply_type = 1
    db.session.add(comment)
    db.session.commit()
    flash('Submit comments successfully.')
    return redirect(url_for('detail', index=index))
Пример #2
0
def reply(index,user_name):
    form = CommentForm()
    if form.validate_on_submit():
        comment = Comment(content=form.content.data)
        comment.user_id = g.user.id
        comment.article_id = index  #
        # comment.reply_type = 2
        comment.to_user = user_name
        db.session.add(comment)
        db.session.commit()
        flash('Submit reply successfully.')
        return redirect(url_for('detail', index=index))
    return render_template('reply.html', title='Reply', form=form)