feat: 仪表盘+催办在休息日跳过填报检查
- 新增 is_working_day() 工具函数,自动跳过周末 + 可配置法定假日 - 仪表盘填报进度新增 is_rest_day 字段,休息日显示灰「休」印章 - 催办调度改用 is_working_day() 替代原始 weekday 检查 - 系统设置新增「法定节假日」配置卡片,支局长可管理假日日期 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,7 @@ async def update_config(
|
||||
):
|
||||
"""Update a single config key. Only directors can change settings."""
|
||||
value = body.get("value", "")
|
||||
valid_keys = {"notification_time"}
|
||||
valid_keys = {"notification_time", "holidays"}
|
||||
|
||||
if key not in valid_keys:
|
||||
raise HTTPException(status_code=400, detail=f"不支持的配置项: {key}")
|
||||
@@ -75,11 +75,23 @@ async def update_config(
|
||||
h, m = _parse_time(value)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
# Persist to DB
|
||||
await _set_config(db, key, value)
|
||||
# Reschedule the APScheduler job
|
||||
await reschedule_daily_check(h, m)
|
||||
return {"key": key, "value": value, "scheduled": f"{h:02d}:{m:02d}"}
|
||||
|
||||
if key == "holidays":
|
||||
# Validate: comma-separated YYYY-MM-DD dates
|
||||
if value.strip():
|
||||
for s in value.split(","):
|
||||
s = s.strip()
|
||||
if s:
|
||||
try:
|
||||
from datetime import date
|
||||
date.fromisoformat(s)
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=400, detail=f"日期格式错误: {s},应为 YYYY-MM-DD")
|
||||
await _set_config(db, key, value)
|
||||
return {"key": key, "value": value}
|
||||
|
||||
await _set_config(db, key, value)
|
||||
return {"key": key, "value": value}
|
||||
|
||||
Reference in New Issue
Block a user