feat: 中文状态显示
This commit is contained in:
@@ -33,6 +33,10 @@ def create_app(config_name='default'):
|
||||
sess.init_app(app)
|
||||
bootstrap.init_app(app)
|
||||
|
||||
# 注册自定义过滤器
|
||||
from .filters import translate_status
|
||||
app.jinja_env.filters['translate_status'] = translate_status
|
||||
|
||||
# 3. 注册蓝图 (Blueprint)
|
||||
# 后面我们会在这里添加蓝图
|
||||
from .routes import main as main_blueprint
|
||||
|
||||
27
app/filters.py
Normal file
27
app/filters.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# app/filters.py
|
||||
# 状态翻译过滤器
|
||||
|
||||
STATUS_TRANSLATIONS = {
|
||||
# 举报状态
|
||||
'pending': '待审核',
|
||||
'in_review': '审核中',
|
||||
'approved': '已批准',
|
||||
'rejected': '已驳回',
|
||||
'revoked': '已撤销',
|
||||
'overturned': '已推翻',
|
||||
|
||||
# 申诉状态
|
||||
'awaiting_admin_reply': '等待管理员回复',
|
||||
'awaiting_user_reply': '等待用户回复',
|
||||
|
||||
# 用户状态
|
||||
'active': '正常',
|
||||
'disabled': '已禁用',
|
||||
|
||||
# 黑名单状态
|
||||
'expired': '已过期'
|
||||
}
|
||||
|
||||
def translate_status(status):
|
||||
"""将英文状态翻译为中文"""
|
||||
return STATUS_TRANSLATIONS.get(status, status)
|
||||
@@ -31,7 +31,7 @@
|
||||
{% if 'closed' in appeal.status %} bg-secondary
|
||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||
{% else %} bg-info text-dark {% endif %}">
|
||||
{{ appeal.status }}
|
||||
{{ appeal.status | translate_status }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ appeal.updated_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{% if user.id == 1 %}
|
||||
<td>
|
||||
<div>角色: <span class="badge bg-danger">{{ user.role }}</span></div>
|
||||
<div>状态: <span class="badge bg-success">{{ user.status }}</span></div>
|
||||
<div>状态: <span class="badge bg-success">{{ user.status | translate_status }}</span></div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-secondary" disabled>不可修改</button>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<li class="list-group-item"><strong>所属站点:</strong> {{ report.reported_pt_site }}</li>
|
||||
<li class="list-group-item"><strong>举报理由:</strong> {{ report.reason_category }}</li>
|
||||
<li class="list-group-item"><strong>举报人:</strong> {{ report.reporter.username }}</li>
|
||||
<li class="list-group-item"><strong>状态:</strong> <strong class="text-capitalize">{{ report.status }}</strong></li>
|
||||
<li class="list-group-item"><strong>状态:</strong> <strong class="text-capitalize">{{ report.status | translate_status }}</strong></li>
|
||||
<li class="list-group-item"><strong>详细描述:</strong><br><span style="white-space: pre-wrap;">{{ report.description }}</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<small class="text-muted">{{ report.reported_pt_site }}</small>
|
||||
</td>
|
||||
<td>{{ report.reporter.username }}</td>
|
||||
<td><span class="badge bg-info text-dark">{{ report.status }}</span></td>
|
||||
<td><span class="badge bg-info text-dark">{{ report.status | translate_status }}</span></td>
|
||||
<td>{{ report.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
<td><a href="{{ url_for('main.report_detail', report_id=report.id) }}" class="btn btn-sm btn-outline-primary">查看详情</a></td>
|
||||
</tr>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||
{% else %} bg-info text-dark {% endif %}">
|
||||
{{ appeal.status }}
|
||||
{{ appeal.status | translate_status }}
|
||||
</span>
|
||||
</p>
|
||||
<hr>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||
{% else %} bg-info text-dark {% endif %}">
|
||||
{{ appeal.status }}
|
||||
{{ appeal.status | translate_status }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ appeal.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{% elif report.status == 'revoked' %} bg-warning text-dark
|
||||
{% elif report.status == 'overturned' %} bg-secondary
|
||||
{% else %} bg-info {% endif %}">
|
||||
{{ report.status }}
|
||||
{{ report.status | translate_status }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ report.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
|
||||
Reference in New Issue
Block a user