def deletecomment(project, comment_id):
comment = Comment.get_by_id(comment_id)
if comment.has_replies():
flash(_('This comment has replies and cannot be deleted'), 'error')
else:
if not current_user.is_authenticated:
flash(_('You must be logged in to delete a comment'), 'error')
else:
if (current_user != comment.owner
and current_user != project.get_master().owner):
flash(_('You are not allowed '
'to delete this thread'), 'error')
else:
comment.delete()
db.session.commit()
flash(_('Comment successfully deleted'), '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'))
评论列表
文章目录