feat: 优化代码结构

This commit is contained in:
DengDai
2025-11-24 13:40:58 +08:00
parent aa516a8d71
commit 148fc78014
8 changed files with 69 additions and 261 deletions

View File

@@ -53,7 +53,7 @@ def create_report():
new_report = Report(
reporter_id=current_user.id,
reported_pt_site=form.reported_pt_site.data,
reported_uid=form.reported_uid.data,
reported_username=form.reported_username.data,
reported_email=form.reported_email.data,
reason_category=form.reason_category.data,
description=form.description.data,
@@ -133,7 +133,7 @@ def report_detail(report_id):
flash('你的审核建议已成功提交。', 'success')
return redirect(url_for('main.report_detail', report_id=report.id))
comments = report.comments.order_by(Comment.timestamp.desc()).all()
comments = report.comments.order_by(Comment.created_at.desc()).all()
return render_template(
'admin/report_detail.html',
@@ -160,9 +160,9 @@ def process_report(report_id, action):
email=report.reported_email,
normalized_email=normalize_email(report.reported_email),
pt_site=report.reported_pt_site,
uid=report.reported_uid,
uid=report.reported_username,
report_id=report.id,
username=report.reported_uid or None
username=report.reported_username or None
)
db.session.add(new_blacklist_entry)
flash('举报已批准,并已将相关信息添加到黑名单。', 'success')
@@ -324,7 +324,7 @@ def appeal_detail(appeal_id):
db.session.commit()
flash('消息已发送。', 'success')
return redirect(url_for('main.appeal_detail', appeal_id=appeal.id))
messages = appeal.messages.order_by(AppealMessage.timestamp.asc()).all()
messages = appeal.messages.order_by(AppealMessage.created_at.asc()).all()
return render_template('appeal_detail.html', appeal=appeal, messages=messages, form=form)
@main.route('/admin/appeals')
@login_required
@@ -351,7 +351,7 @@ def decide_appeal(appeal_id):
if action == 'approve':
# 批准申诉:删除黑名单记录,更新申诉状态
blacklist_entry = appeal.blacklist_entry
blacklist_entry.status = 'revoked' # 将黑名单条目状态改为已撤销
blacklist_entry.status = 'revoked' # 将黑名单条目状态改为"已撤销"
appeal.status = 'approved' # 同时更新申诉本身的状态
if blacklist_entry.report:
# 使用 'overturned' (已推翻) 可能比 'revoked' 更能描述 Report 的状态
@@ -367,9 +367,13 @@ def decide_appeal(appeal_id):
elif action == 'reject':
# 驳回申诉:仅更新申诉状态
appeal.status = 'rejected'
db.session.add(appeal)
flash(f'已驳回申诉 #{appeal.id}', 'info')
else:
flash('无效操作。', 'danger')
return redirect(url_for('main.appeal_list'))
db.session.commit()
return redirect(url_for('main.appeal_list'))
@main.route('/admin/sites', methods=['GET', 'POST'])