def editcomment(project, comment_id):
comment = Comment.get_by_id(comment_id)
form = CommentForm(request.form,
comment=comment.content)
if current_user != comment.owner:
flash(_('You are not allowed to edit this comment'), 'error')
if 'return_url' in request.args:
return redirect(urllib.unquote(request.args['return_url']))
else:
return redirect(url_for('branches.view', project=project.name,
branch='master', filename='index'))
if request.method == 'POST' and form.validate():
comment.content = form.comment.data
db.session.commit()
flash(_('Comment modified successfully'), 'info')
if 'return_url' in request.args:
return redirect(urllib.unquote(request.args['return_url']))
else:
return redirect(url_for('branches.view', project=project.name,
branch='master', filename='index'))
threads = (Thread.query.filter_by(id=comment.thread.id)
.order_by(desc(Thread.posted_at)))
return render_template('threads/newcomment.html', form=form)
评论列表
文章目录