feat: 增添个人举报与申诉查询
This commit is contained in:
@@ -309,6 +309,9 @@ def appeal_detail(appeal_id):
|
||||
abort(403)
|
||||
form = AppealMessageForm()
|
||||
if form.validate_on_submit():
|
||||
if appeal.status in ['approved', 'rejected']:
|
||||
flash('该申诉已关闭,无法继续对话。', 'warning')
|
||||
return redirect(url_for('main.appeal_detail', appeal_id=appeal.id))
|
||||
msg = AppealMessage(
|
||||
body=form.body.data,
|
||||
author_id=current_user.id,
|
||||
@@ -319,7 +322,7 @@ def appeal_detail(appeal_id):
|
||||
appeal.status = 'awaiting_user_reply'
|
||||
else:
|
||||
appeal.status = 'awaiting_admin_reply'
|
||||
|
||||
|
||||
db.session.add(msg)
|
||||
db.session.commit()
|
||||
flash('消息已发送。', 'success')
|
||||
@@ -347,6 +350,9 @@ def appeal_list():
|
||||
@permission_required('admin') # 必须是管理员
|
||||
def decide_appeal(appeal_id):
|
||||
appeal = Appeal.query.get_or_404(appeal_id)
|
||||
if appeal.status in ['approved', 'rejected']:
|
||||
flash('该申诉已处理,无法重复操作。', 'warning')
|
||||
return redirect(url_for('main.appeal_detail', appeal_id=appeal.id))
|
||||
action = request.form.get('action')
|
||||
if action == 'approve':
|
||||
# 批准申诉:删除黑名单记录,更新申诉状态
|
||||
@@ -376,6 +382,24 @@ def decide_appeal(appeal_id):
|
||||
db.session.commit()
|
||||
return redirect(url_for('main.appeal_list'))
|
||||
|
||||
@main.route('/my/reports')
|
||||
@login_required
|
||||
def my_reports():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
reports_pagination = Report.query.filter_by(reporter_id=current_user.id).order_by(
|
||||
Report.created_at.desc()
|
||||
).paginate(page=page, per_page=20, error_out=False)
|
||||
return render_template('my_reports.html', reports=reports_pagination)
|
||||
|
||||
@main.route('/my/appeals')
|
||||
@login_required
|
||||
def my_appeals():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
appeals_pagination = Appeal.query.filter_by(appealer_id=current_user.id).order_by(
|
||||
Appeal.created_at.desc()
|
||||
).paginate(page=page, per_page=20, error_out=False)
|
||||
return render_template('my_appeals.html', appeals=appeals_pagination)
|
||||
|
||||
@main.route('/admin/sites', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
|
||||
Reference in New Issue
Block a user