fix(project): meeting task table shared per week on the server (others' rows were invisible)
- Cause: the table lived only in each browser's localStorage - project_db migration 025 goal_meeting_tasks (week_start, parent_id for subtask rows, task_id) - API list/add/update/delete + apply; apply locks the row and creates the task once via the same helper as the task window (_create_task_for: membership, assignee check, notifications) - Non-members see other people's rows with project/section/task hidden; only member projects can be picked; completed meeting is read-only (409) - Client saves per field, refreshes every 30s / on focus, uploads rows left in this browser once - Docs (DEPLOYMENT 025, PROJECT_MODULE, help, CLAUDE.md); tests (real PostgreSQL incl. 4 concurrent applies -> one task, jsdom) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1465,6 +1465,16 @@ def api_create_task(
|
||||
) -> JSONResponse:
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
task, skipped = _create_task_for(request, st, user, project_id, payload, bg)
|
||||
return JSONResponse({"task": task, "mention_skipped": skipped}, status_code=201)
|
||||
|
||||
|
||||
def _create_task_for(
|
||||
request: Request, st: Any, user: dict[str, Any], project_id: int, payload: dict[str, Any],
|
||||
bg: BackgroundTasks,
|
||||
) -> tuple[dict[str, Any], list[str]]:
|
||||
"""작업 만들기 공통(작업 창·회의록 작업 등록 [적용]) — 권한(멤버)·담당자 확인·만들기·자동 협업자·배정/완료 알림·@태그.
|
||||
돌려주는 값: (작업, 태그하지 못한 이메일)."""
|
||||
_require_manage(request, st, user, project_id)
|
||||
project = st.get_project(project_id=project_id)
|
||||
if project is None:
|
||||
@@ -1525,7 +1535,7 @@ def api_create_task(
|
||||
emails=store.extract_mentions_from_html(task.get("description") or ""),
|
||||
actor=user["email"], project_name=project["name"],
|
||||
)
|
||||
return JSONResponse({"task": task, "mention_skipped": skipped}, status_code=201)
|
||||
return task, skipped
|
||||
|
||||
|
||||
_ASSIGNEE_DENIED = "담당자는 이 프로젝트를 볼 수 있는 사람(멤버·소유자·관리자)이어야 합니다."
|
||||
@@ -2946,6 +2956,8 @@ def _goal_call(fn: Any, *args: Any, **kwargs: Any) -> Any:
|
||||
raise HTTPException(status_code=409, detail="회의가 완료되어 수정할 수 없습니다. 관리자가 [완료 해제]하면 다시 고칠 수 있습니다.")
|
||||
except store.MeetingMigration022Needed:
|
||||
raise HTTPException(status_code=503, detail="회의 완료 기능은 project_db 마이그레이션 022 적용 후 사용할 수 있습니다.")
|
||||
except store.MeetingTaskMigrationNeeded:
|
||||
raise HTTPException(status_code=503, detail="작업 등록 표(모두가 같이 보는 주차별 표)는 project_db 마이그레이션 025 적용 후 사용할 수 있습니다.")
|
||||
except store.MeetingMigration020Needed:
|
||||
raise HTTPException(status_code=503, detail="새 주차·결과 글·주차별 목표는 project_db 마이그레이션 020 적용 후 사용할 수 있습니다.")
|
||||
except store.GoalCellConflict as exc:
|
||||
@@ -3739,6 +3751,110 @@ def api_move_meeting_item(request: Request, item_id: int, payload: dict[str, Any
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
# ── 회의록 작업 등록 표(025) — 주차별 한 표를 서버에(예전엔 각자 브라우저에만 있어 다른 사람 줄이 안 보였다) ──
|
||||
# 보기·고치기: 회의록을 볼 수 있는 사람 누구나(회의 완료면 잠금). 줄에 고른 프로젝트는 내가 멤버인 것만 고를 수 있고,
|
||||
# 내가 멤버가 아닌 프로젝트를 가리키는 남의 줄은 프로젝트·섹션 이름·만든 작업을 가린다. [적용] = 그 프로젝트 멤버만.
|
||||
def _quick_view(st: Any, user: dict[str, Any], rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
seen: dict[int, bool] = {}
|
||||
out = []
|
||||
for r in rows:
|
||||
pid = r.get("project_id")
|
||||
ok = True if pid is None else seen.setdefault(pid, access.can_manage_project(st, user, pid))
|
||||
r = dict(r, visible=ok, registered=r.get("task_id") is not None) # 등록됨 여부는 누구에게나(작업 내용은 멤버만)
|
||||
if not ok:
|
||||
r.update(project_name="(볼 수 없는 프로젝트)", stage_name="", task_title="", task_id=None,
|
||||
task_project_id=None)
|
||||
out.append(r)
|
||||
return out
|
||||
|
||||
|
||||
def _quick_fields(st: Any, user: dict[str, Any], payload: dict[str, Any]) -> dict[str, Any]:
|
||||
fields = {k: payload[k] for k in ("title", "assignee_email", "project_id", "stage_id") if k in payload}
|
||||
pid = fields.get("project_id")
|
||||
if pid not in (None, ""):
|
||||
try:
|
||||
pid = int(pid)
|
||||
except (TypeError, ValueError):
|
||||
raise HTTPException(status_code=400, detail="프로젝트 값이 올바르지 않습니다.")
|
||||
if not access.can_manage_project(st, user, pid):
|
||||
raise HTTPException(status_code=403, detail="내가 멤버인 프로젝트만 고를 수 있습니다.")
|
||||
return fields
|
||||
|
||||
|
||||
@router.get("/api/goals/meetings/{week_start}/quick-tasks")
|
||||
def api_list_quick_tasks(request: Request, week_start: str) -> JSONResponse:
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
ws = _goal_call(store.validate_week_start, week_start)
|
||||
rows = _goal_call(st.list_meeting_tasks, week_start=ws)
|
||||
return JSONResponse({"tasks": _quick_view(st, user, rows)})
|
||||
|
||||
|
||||
@router.post("/api/goals/meetings/{week_start}/quick-tasks")
|
||||
def api_add_quick_task(request: Request, week_start: str, payload: dict[str, Any] = Body(default={})) -> JSONResponse:
|
||||
"""줄 추가 {title?, assignee_email?, project_id?, stage_id?, parent_id?(세부 작업 줄), task_id?(예전 브라우저 표의 등록된 줄)}."""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
ws = _goal_call(store.validate_week_start, week_start)
|
||||
fields = _quick_fields(st, user, payload)
|
||||
parent = payload.get("parent_id")
|
||||
try:
|
||||
parent_id = int(parent) if parent not in (None, "") else None
|
||||
except (TypeError, ValueError):
|
||||
raise HTTPException(status_code=400, detail="parent_id 가 올바르지 않습니다.")
|
||||
task_id = None
|
||||
if payload.get("task_id") not in (None, ""):
|
||||
# 옮겨 오는 등록된 줄 — 그 작업을 지금 내가 원 소속으로 다룰 수 있을 때만 이어 붙인다(남의 작업 id 를 끌어오지 못하게)
|
||||
try:
|
||||
t = st.get_task(task_id=int(payload["task_id"]))
|
||||
except (TypeError, ValueError):
|
||||
t = None
|
||||
if t is not None and access.task_access(st, user, t) == access.FULL:
|
||||
task_id = int(t["id"])
|
||||
row = _goal_call(st.add_meeting_task, week_start=ws, fields=fields, by=user["email"],
|
||||
parent_id=parent_id, task_id=task_id)
|
||||
return JSONResponse({"task": _quick_view(st, user, [row])[0]}, status_code=201)
|
||||
|
||||
|
||||
@router.put("/api/goals/meeting-quick-tasks/{item_id}")
|
||||
def api_update_quick_task(request: Request, item_id: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
row = _goal_call(st.update_meeting_task, item_id=item_id, fields=_quick_fields(st, user, payload), by=user["email"])
|
||||
return JSONResponse({"task": _quick_view(st, user, [row])[0]})
|
||||
|
||||
|
||||
@router.delete("/api/goals/meeting-quick-tasks/{item_id}")
|
||||
def api_delete_quick_task(request: Request, item_id: int) -> JSONResponse:
|
||||
"""줄 지우기. 이미 만든 작업은 화면이 따로 지운다(DELETE /api/tasks/{id} — 그 프로젝트 멤버만, 휴지통)."""
|
||||
_require_user(request)
|
||||
st = _db_or_503(request)
|
||||
_goal_call(st.delete_meeting_task, item_id=item_id)
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
@router.post("/api/goals/meeting-quick-tasks/{item_id}/apply")
|
||||
def api_apply_quick_task(request: Request, item_id: int, bg: BackgroundTasks) -> JSONResponse:
|
||||
"""[적용] — 그 줄로 프로젝트에 작업을 만든다(작업 창과 같은 권한·알림). 줄을 잠그고 한 번만 — 이미 만들었으면 그 결과."""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
|
||||
def create(row: dict[str, Any], parent_task_id: int | None) -> dict[str, Any]:
|
||||
if not row["title"].strip():
|
||||
raise ValueError("작업 제목을 쓰세요.")
|
||||
if row["project_id"] is None:
|
||||
raise ValueError("프로젝트를 고르세요.")
|
||||
rec = access.default_user_lookup(row["assignee_email"]) if row["assignee_email"] else None
|
||||
payload = {"title": row["title"].strip(), "stage_id": None if parent_task_id else row["stage_id"],
|
||||
"assignee_email": row["assignee_email"],
|
||||
"assignee_name": (rec or {}).get("name") or (row["assignee_email"].split("@")[0] if row["assignee_email"] else ""),
|
||||
"parent_task_id": parent_task_id}
|
||||
return _create_task_for(request, st, user, int(row["project_id"]), payload, bg)[0]
|
||||
|
||||
row, made = _goal_call(st.apply_meeting_task, item_id=item_id, create=create)
|
||||
return JSONResponse({"task": _quick_view(st, user, [row])[0], "created": made}, status_code=201 if made else 200)
|
||||
|
||||
|
||||
@router.post("/api/goals/meeting-items/{item_id}/move-section")
|
||||
def api_move_meeting_section(request: Request, item_id: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
|
||||
"""구역(첫 열 "구분") 통째로 위/아래 {direction: -1|1} — item_id = 그 구역의 아무 줄. 줄 순서와 같은 권한(누구나,
|
||||
|
||||
Reference in New Issue
Block a user