refactor(projects): 优先级/项目说明整链下线——前端零读写、库内 0 行数据、导出恒为「P2 中」:Project.priority/description 模型列 + ProjectIn/Patch 字段 + to_dict 键 + /export/projects「优先级」列(测试列号同步)+ /meta priorities + constants.PRIORITIES;两列登记 STALE_COLUMNS 启动清老库。pytest 93 passed
parent
7d543851c6
commit
1ca2cf1dd1
|
|
@ -488,7 +488,7 @@ python scripts/legacy/add_entry_date.py --force # 全部重算
|
|||
```
|
||||
# 项目管理(长期重点项目)
|
||||
Period(周期: 年/月/周, sort_key)
|
||||
└── Project(分类, 负责人 owners[0], 其他负责人, 团队成员, 状态, 优先级, 重点标记, 进度, 标签)
|
||||
└── Project(分类, 负责人 owners[0], 其他负责人, 团队成员, 状态, 重点标记, 进度, 标签)
|
||||
├── Task(子任务)
|
||||
└── Update(执行情况: 正文, 摘要, 进度, 状态, 风险, 下一步, 来源, 原文)
|
||||
|
||||
|
|
@ -625,7 +625,7 @@ GET|DELETE /api/rbac/logs 操作审计(服务端分页)?username=
|
|||
/ DELETE 按 days 清理
|
||||
|
||||
# 通用
|
||||
GET /api/meta 状态字典 / 优先级 / 菜单 / AI 配置状态
|
||||
GET /api/meta 状态字典 / 菜单 / AI 配置状态
|
||||
GET /api/periods 周列表 + 按月聚合(today_id = 今天所在的周,顶栏默认落它;没有会自动补建)
|
||||
POST /api/periods 新增周期(传 label 如「9月第1周」,年份自动接续;重复提交返回已有的)
|
||||
DELETE /api/periods/{id} 删除空周期(有记录则拒绝)
|
||||
|
|
|
|||
|
|
@ -15,14 +15,6 @@ STATUSES = [
|
|||
STATUS_MAP = {code: (name, color) for code, name, color in STATUSES}
|
||||
STATUS_CODES = [c for c, _, _ in STATUSES]
|
||||
|
||||
# 项目优先级
|
||||
PRIORITIES = [
|
||||
("p0", "P0 最高", "#dc2626"),
|
||||
("p1", "P1 高", "#d97706"),
|
||||
("p2", "P2 中", "#2563eb"),
|
||||
("p3", "P3 低", "#6b7280"),
|
||||
]
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 权限菜单目录(前后端共用:键是权限标识,顺序即权限管理页里的展示顺序)
|
||||
# rw = 可编辑(含新增/修改/删除/导出写入口)
|
||||
|
|
|
|||
|
|
@ -150,10 +150,9 @@ class Project(Base, TimestampMixin):
|
|||
other_owners: Mapped[str | None] = mapped_column(String(512), nullable=True) # 其他负责人
|
||||
members: Mapped[str | None] = mapped_column(String(512), nullable=True) # 团队成员
|
||||
status: Mapped[str] = mapped_column(String(32), default="in_progress", nullable=False)
|
||||
priority: Mapped[str] = mapped_column(String(8), default="p2", nullable=False)
|
||||
# priority / description 两列 2026-11-04 下线:无任何界面读写,导出恒为「P2 中」
|
||||
is_key: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) # 重点标记
|
||||
progress: Mapped[float] = mapped_column(Float, default=0.0, nullable=False) # 最新进度 %
|
||||
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
archived: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
sort_order: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||||
|
||||
|
|
@ -176,10 +175,8 @@ class Project(Base, TimestampMixin):
|
|||
"owners": all_owners(self.owner, self.other_owners),
|
||||
"members": split_people(self.members),
|
||||
"status": self.status,
|
||||
"priority": self.priority,
|
||||
"is_key": self.is_key,
|
||||
"progress": round(self.progress or 0, 1),
|
||||
"description": self.description,
|
||||
"archived": self.archived,
|
||||
"sort_order": self.sort_order,
|
||||
"tags": [t.to_dict() for t in self.tags],
|
||||
|
|
|
|||
|
|
@ -189,9 +189,6 @@ def meta(db: Session = Depends(get_db)):
|
|||
"statuses": [
|
||||
{"code": c, "name": n, "color": col} for c, n, col in constants.STATUSES
|
||||
],
|
||||
"priorities": [
|
||||
{"code": c, "name": n, "color": col} for c, n, col in constants.PRIORITIES
|
||||
],
|
||||
"ai": {
|
||||
"enabled": ai_enabled(db),
|
||||
"model": s.get("ai_model"),
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ def export_projects(
|
|||
|
||||
periods = {p.id: p for p in db.query(Period).all()}
|
||||
headers = [
|
||||
"项目名称", "分类", "负责人", "状态", "优先级", "重点",
|
||||
"项目名称", "分类", "负责人", "状态", "重点",
|
||||
"进度(%)", "标签", "子任务数", "执行记录数", "最近更新周期", "归档",
|
||||
]
|
||||
status_names = {
|
||||
|
|
@ -211,7 +211,6 @@ def export_projects(
|
|||
p.category.name if p.category else "未分类",
|
||||
p.owner or "",
|
||||
status_names.get(p.status, p.status),
|
||||
(p.priority or "").upper(),
|
||||
"是" if p.is_key else "",
|
||||
round(p.progress or 0, 1),
|
||||
"、".join(t.name for t in p.tags),
|
||||
|
|
@ -226,7 +225,7 @@ def export_projects(
|
|||
"项目管理",
|
||||
headers,
|
||||
rows,
|
||||
widths=[46, 12, 12, 10, 9, 7, 10, 24, 11, 12, 18, 7],
|
||||
widths=[46, 12, 12, 10, 7, 10, 24, 11, 12, 18, 7],
|
||||
title="项目管理清单",
|
||||
)
|
||||
return _resp(content, "项目管理清单")
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ STALE_COLUMNS: tuple[tuple[str, str], ...] = (
|
|||
("tasks", "sort_order"), # 子任务实际按 id 排序,此列只写不读
|
||||
("periods", "start_date"), # 周期起止由 year/month/week 推导,两列从未被读取
|
||||
("periods", "end_date"),
|
||||
("projects", "priority"), # 优先级无界面读写,导出恒为 P2(NOT NULL 列,必须清)
|
||||
("projects", "description"),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ class ProjectIn(BaseModel):
|
|||
owners: list[str] | None = None # 多负责人(第一位是主负责人),整体替换
|
||||
members: list[str] | None = None # 团队成员,整体替换
|
||||
status: str = "in_progress"
|
||||
priority: str = "p2"
|
||||
is_key: bool = False
|
||||
progress: float = 0
|
||||
description: str | None = None
|
||||
archived: bool = False
|
||||
tags: list[str] = Field(default_factory=list) # 标签名,自动创建
|
||||
|
||||
|
|
@ -27,10 +25,8 @@ class ProjectPatch(BaseModel):
|
|||
owners: list[str] | None = None # 不传即不改;传空数组即清空
|
||||
members: list[str] | None = None
|
||||
status: str | None = None
|
||||
priority: str | None = None
|
||||
is_key: bool | None = None
|
||||
progress: float | None = None
|
||||
description: str | None = None
|
||||
archived: bool | None = None
|
||||
tags: list[str] | None = None
|
||||
|
||||
|
|
|
|||
|
|
@ -356,8 +356,8 @@ def test_项目导出含归档开关与统计列(h):
|
|||
_, rows = _sheet(h.admin.get("/api/export/projects", params={"archived": "all"}))
|
||||
assert "导出-已归档项目" in [r[0] for r in rows[3:]] # 整库留档要显式 archived=all
|
||||
row = next(r for r in rows[3:] if r[0] == "导出-常规项目")
|
||||
assert row[3] == "进行中" and row[5] == "是" and row[9] == 1
|
||||
assert row[10] and "第" in row[10] # 最近更新周期写了周次
|
||||
assert row[3] == "进行中" and row[4] == "是" and row[8] == 1
|
||||
assert row[9] and "第" in row[9] # 最近更新周期写了周次
|
||||
|
||||
_, rows = _sheet(h.admin.get("/api/export/projects", params={"archived": "false"}))
|
||||
names = [r[0] for r in rows[3:]]
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ def test_有记录的周期不能删(h):
|
|||
assert h.admin.delete("/api/periods/424242").status_code == 404
|
||||
|
||||
|
||||
def test_元信息给状态优先级和AI状态(h):
|
||||
def test_元信息给状态字典和AI状态(h):
|
||||
meta = h.admin.get("/api/meta").json()
|
||||
assert [x["code"] for x in meta["statuses"]] == [c for c, _, _ in constants.STATUSES]
|
||||
assert [x["code"] for x in meta["priorities"]] == [c for c, _, _ in constants.PRIORITIES]
|
||||
assert "priorities" not in meta # 优先级已随 Project.priority 下线
|
||||
assert meta["ai"]["enabled"] is False # 没配 Key:走本地规则
|
||||
assert meta["ai"]["has_key"] is False
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ def test_项目字段与人员标签的写入(h):
|
|||
cat = h.category("交付项目")
|
||||
p = h.project("智慧园区", category_id=cat["id"], owners=["张三", "李四"],
|
||||
members=["王五", "赵六"], tags=["新客户", "重点"], is_key=True,
|
||||
progress=35, priority="p1", description="备注说明")
|
||||
progress=35)
|
||||
assert p["owner"] == "张三" and p["owners"] == ["张三", "李四"] # 第一位是主负责人
|
||||
assert p["members"] == ["王五", "赵六"]
|
||||
assert {t["name"] for t in p["tags"]} == {"新客户", "重点"}
|
||||
|
|
|
|||
Loading…
Reference in New Issue