def deletethread(project, thread_id):
thread = Thread.get_by_id(thread_id)
if Comment.query.filter_by(thread_id=thread_id).first():
flash(_('Thread is not empty'), 'error')
else:
thread = Thread.query.filter_by(id=thread_id).first()
if not current_user.is_authenticated:
flash(_('You must be logged in to delete a thread'), 'error')
else:
if (current_user != thread.owner
and current_user != project.get_master().owner):
flash(_('You are not allowed to delete this thread'), 'error')
else:
thread.delete()
db.session.commit()
flash(_('Thread 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'))
评论列表
文章目录