feat: 中文状态显示
This commit is contained in:
@@ -33,6 +33,10 @@ def create_app(config_name='default'):
|
|||||||
sess.init_app(app)
|
sess.init_app(app)
|
||||||
bootstrap.init_app(app)
|
bootstrap.init_app(app)
|
||||||
|
|
||||||
|
# 注册自定义过滤器
|
||||||
|
from .filters import translate_status
|
||||||
|
app.jinja_env.filters['translate_status'] = translate_status
|
||||||
|
|
||||||
# 3. 注册蓝图 (Blueprint)
|
# 3. 注册蓝图 (Blueprint)
|
||||||
# 后面我们会在这里添加蓝图
|
# 后面我们会在这里添加蓝图
|
||||||
from .routes import main as main_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
|
{% if 'closed' in appeal.status %} bg-secondary
|
||||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||||
{% else %} bg-info text-dark {% endif %}">
|
{% else %} bg-info text-dark {% endif %}">
|
||||||
{{ appeal.status }}
|
{{ appeal.status | translate_status }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ appeal.updated_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
<td>{{ appeal.updated_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
{% if user.id == 1 %}
|
{% if user.id == 1 %}
|
||||||
<td>
|
<td>
|
||||||
<div>角色: <span class="badge bg-danger">{{ user.role }}</span></div>
|
<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>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-sm btn-secondary" disabled>不可修改</button>
|
<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.reported_pt_site }}</li>
|
||||||
<li class="list-group-item"><strong>举报理由:</strong> {{ report.reason_category }}</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> {{ 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>
|
<li class="list-group-item"><strong>详细描述:</strong><br><span style="white-space: pre-wrap;">{{ report.description }}</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<small class="text-muted">{{ report.reported_pt_site }}</small>
|
<small class="text-muted">{{ report.reported_pt_site }}</small>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ report.reporter.username }}</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>{{ 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>
|
<td><a href="{{ url_for('main.report_detail', report_id=report.id) }}" class="btn btn-sm btn-outline-primary">查看详情</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
||||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||||
{% else %} bg-info text-dark {% endif %}">
|
{% else %} bg-info text-dark {% endif %}">
|
||||||
{{ appeal.status }}
|
{{ appeal.status | translate_status }}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
{% if appeal.status in ['approved', 'rejected'] %} bg-secondary
|
||||||
{% elif 'user' in appeal.status %} bg-warning text-dark
|
{% elif 'user' in appeal.status %} bg-warning text-dark
|
||||||
{% else %} bg-info text-dark {% endif %}">
|
{% else %} bg-info text-dark {% endif %}">
|
||||||
{{ appeal.status }}
|
{{ appeal.status | translate_status }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ appeal.created_at.strftime('%Y-%m-%d %H:%M') }}</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 == 'revoked' %} bg-warning text-dark
|
||||||
{% elif report.status == 'overturned' %} bg-secondary
|
{% elif report.status == 'overturned' %} bg-secondary
|
||||||
{% else %} bg-info {% endif %}">
|
{% else %} bg-info {% endif %}">
|
||||||
{{ report.status }}
|
{{ report.status | translate_status }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ report.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
<td>{{ report.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user