feat(project): 세션 기본 담당자
세션 편집 창에서 기본 담당자(프로젝트 멤버·owner)를 지정하면, 그 세션에 업무를 만들거나 다른 세션에서 옮겨올 때 담당자가 빈 업무만 자동 배정. 이미 담당자가 있으면 그대로. 보드 세션 머리에 담당자 아바타 표시, 새 업무 팝업은 기본 담당자를 미리 채움. 자동 배정도 일반 배정처럼 알림·팔로워·메일 처리. DB: project_db_009 (project_stages.default_assignee_email). 미적용이어도 to_jsonb 로 읽어 동작, 지정 시도만 503 안내. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,7 @@ from fastapi.responses import (
|
||||
JSONResponse,
|
||||
RedirectResponse,
|
||||
)
|
||||
from psycopg.errors import UndefinedColumn
|
||||
|
||||
from app.timezone import today_kst
|
||||
|
||||
@@ -992,6 +993,7 @@ def api_add_stage(
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
_require_manage(request, st, user, project_id)
|
||||
dae = _stage_default_assignee_arg(st, project_id, payload)
|
||||
try:
|
||||
stage = st.add_stage(
|
||||
project_id=project_id,
|
||||
@@ -999,12 +1001,36 @@ def api_add_stage(
|
||||
is_done_stage=bool(payload.get("is_done_stage", False)),
|
||||
color=payload.get("color"),
|
||||
created_by=user["email"],
|
||||
default_assignee_email="" if dae is ... else dae,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
except UndefinedColumn:
|
||||
raise HTTPException(status_code=503, detail=_STAGE_ASSIGNEE_MIGRATION_MSG)
|
||||
return JSONResponse({"stage": stage}, status_code=201)
|
||||
|
||||
|
||||
_STAGE_ASSIGNEE_MIGRATION_MSG = (
|
||||
"세션 기본 담당자 기능이 아직 준비되지 않았습니다(DB 마이그레이션 009 필요)."
|
||||
)
|
||||
|
||||
|
||||
def _stage_default_assignee_arg(st: Any, project_id: int, payload: dict[str, Any]) -> Any:
|
||||
"""payload 의 세션 기본 담당자 — 키가 없으면 `...`(변경 안 함), 빈 값이면 ''
|
||||
(해제). 값이 있으면 그 프로젝트 멤버 또는 owner 여야 한다(업무 담당자
|
||||
후보와 같은 기준)."""
|
||||
if "default_assignee_email" not in payload:
|
||||
return ...
|
||||
email = store.norm_str(payload.get("default_assignee_email") or "", lower=True)
|
||||
if email:
|
||||
allowed = {m["user_email"] for m in st.list_members(project_id=project_id)}
|
||||
project = st.get_project(project_id=project_id) or {}
|
||||
allowed.add(store.norm_str(project.get("owner_email") or "", lower=True))
|
||||
if email not in allowed:
|
||||
raise HTTPException(status_code=400, detail="기본 담당자는 이 프로젝트 멤버여야 합니다.")
|
||||
return email
|
||||
|
||||
|
||||
def _stage_of_project(st: Any, stage_id: int, project_id: int) -> dict[str, Any]:
|
||||
"""URL 의 세션이 URL 의 프로젝트 것인지 확인. 권한 검사는 project_id 로
|
||||
하므로, 이걸 안 보면 아무 프로젝트 멤버나 남의 세션을 고칠 수 있다."""
|
||||
@@ -1706,15 +1732,19 @@ def api_update_stage(
|
||||
st = _db_or_503(request)
|
||||
_require_manage(request, st, user, project_id)
|
||||
_stage_of_project(st, stage_id, project_id)
|
||||
dae = _stage_default_assignee_arg(st, project_id, payload)
|
||||
try:
|
||||
stage = st.update_stage(
|
||||
stage_id=stage_id,
|
||||
name=payload.get("name"),
|
||||
is_done_stage=payload.get("is_done_stage"),
|
||||
color=payload.get("color", ...),
|
||||
default_assignee_email=dae,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
except UndefinedColumn:
|
||||
raise HTTPException(status_code=503, detail=_STAGE_ASSIGNEE_MIGRATION_MSG)
|
||||
except KeyError:
|
||||
raise HTTPException(status_code=404, detail="단계를 찾을 수 없습니다.")
|
||||
return JSONResponse({"stage": stage})
|
||||
|
||||
Reference in New Issue
Block a user