feat(project): 업무를 왼쪽 프로젝트로 끌어 다른 프로젝트로 이동(섹션 선택 창)

- 보드 카드를 사이드바 프로젝트 줄에 놓으면 섹션 선택 창 → POST /api/tasks/{id}/move-project
- 세부 업무(모든 단계)까지 한 트랜잭션으로 이동, 섹션 기본 담당자·완료 섹션 규칙, 대상 쪽 연결 정리
- 원 소속 권한 + 대상 프로젝트 멤버만, 대상 프로젝트를 볼 수 없는 담당자·협업자는 화면에 안내

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 13:34:51 +09:00
parent 941b35a7a6
commit c317d7bb5d
18 changed files with 400 additions and 18 deletions
+54
View File
@@ -1740,6 +1740,60 @@ def api_move_subtask(
return JSONResponse({"task": task})
@router.post("/api/tasks/{task_id}/move-project")
def api_move_task_project(
request: Request,
task_id: int,
bg: BackgroundTasks,
payload: dict[str, Any] = Body(...),
) -> JSONResponse:
"""메인 업무를 다른 프로젝트로 옮긴다 — 보드 카드·목록 줄을 왼쪽 프로젝트 목록으로 드래그 → 섹션 선택 창.
body: {"project_id": 대상, "stage_id": 대상 섹션 또는 null}. 원 소속 권한(FULL) + 대상 프로젝트 멤버여야 한다.
세부 업무는 함께 옮겨진다. 응답의 `unseen` = 대상 프로젝트를 볼 수 없는 담당자·협업자(화면이 안내).
"""
user = _require_user(request)
st = _db_or_503(request)
existing = _task_or_404(st, task_id)
_require_task(st, user, existing, write=True)
try:
target = int(payload.get("project_id"))
except (TypeError, ValueError):
raise HTTPException(status_code=400, detail="옮길 프로젝트(project_id)가 필요합니다.")
_require_manage(request, st, user, target)
project = st.get_project(project_id=target)
if project is None:
raise HTTPException(status_code=404, detail="프로젝트를 찾을 수 없습니다.")
try:
task = st.move_task_to_project(
task_id=task_id, project_id=target, stage_id=payload.get("stage_id"),
actor=user["email"], assignee_allowed=_registered_project_user,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc))
except KeyError as exc:
raise HTTPException(status_code=404, detail=str(exc))
task.pop("_moved_ids", None)
newly_assigned = task.pop("_newly_assigned", None)
if newly_assigned: # 대상 섹션 기본 담당자가 자동 배정됨 — 일반 배정과 같은 알림
_follow(st, task["id"], [newly_assigned])
_inbox(
st, recipients=[newly_assigned], actor=user["email"], project_id=target, task_id=task["id"],
ntype="assigned", title=f"업무 배정: {task['title']}",
body=f"{project['name']} · 마감 {task.get('due_date') or '-'}",
)
if task.pop("_newly_completed", False):
_notify_completed(bg, request, st, project=project, task=task, actor=user["email"])
people = [task.get("assignee_email") or ""]
try:
people += st.list_followers(task_id=task_id)
except Exception: # noqa: BLE001 - 008 미적용
pass
unseen = sorted({store.norm_str(e, lower=True) for e in people if e} -
set(access.filter_recipients(st, task, [e for e in people if e])))
return JSONResponse({"task": task, "unseen": unseen})
# ────────────────────────────────────────────────────────────
# JSON API — 팔로워 (아사나의 협업자)
# ────────────────────────────────────────────────────────────