fix(project): 권한 우회·작업 혼선·저장 유실 등 16개 항목 수정 — 지금 권한 기준·읽기 전용 연결 작업·원자적 파일 댓글
권한(서버) - 공통 권한 모듈 access.py: 모든 판단을 "지금" 권한으로 — 내 작업·수신함·알림·멘션·검색·상세·공유 링크· 댓글·첨부·알림/메일 수신자에서 권한을 잃은 사람 제외(기록은 이력으로 보존) - 소유자 변경·남을 소유자로 지정한 생성은 관리자만, 새 소유자는 권한 있는 등록 사용자 - 삭제는 생성자 규칙 + 지금 권한(멤버에서 빠진 생성자 거절), 댓글 수정·삭제도 지금 권한 - @태그는 볼 수 있는 사람만(mention_skipped), 태그 후보 all-users?task_id=, 새 담당자 권한 검사 - 연결(멀티호밍) 작업은 연결된 프로젝트 멤버에게 읽기 전용(task_link_scope), 볼 수 없는 연결 프로젝트 숨김 저장·동기화(화면) - 작업 창 세대(taskGen)·블록 ctxSeq 로 늦은 A 응답이 B 를 덮지 않게(A→B, A→B→A, 이미지 업로드 중 전환) - 자동 저장 성공/실패 반환, 실패 칸 재시도, 닫기·전환 전 저장 확인(버리기/계속 편집), 미저장 이탈 경고 - 실시간 동기화 observed/applied 분리·실패 재시도·겹침 방지, snapshot?scope=all 로 전체 범위 반영·권한 회수 안내 - 한국시간 기준 오늘(kstTodayIso), 한글 조합 중 Enter 는 제출하지 않음, 댓글 연타·재전송 중복 방지(client_token) 기타 - 파일 댓글은 본문+파일 한 트랜잭션(POST /comments/files), 실패 파일 표시·유지, 작업 창 댓글에 첨부 표시 - 날짜 범위 검증(부분 수정은 최종 상태), 완료 섹션에 바로 만든 작업 완료 처리·알림 - 마감 알림 발송 기록+수신함 알림 원자적(실패 시 재시도), 권한 없는 수신자 제외 - 테스트: tests/test_project_module.py(로컬 PostgreSQL 11개), tests/js/project_ui.test.js(jsdom 51개) - 문서(PROJECT_MODULE 6-10·도움말·CLAUDE.md), project.js/css 캐시 버전 20260930g, 새 마이그레이션·환경변수 없음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
"""프로젝트 관리 — 현재 접근 권한의 공통 기준(서버).
|
||||
|
||||
라우터·마감 알림이 같은 규칙을 쓰도록 한 곳에 모은다. 모든 판단은 "지금" 기준이다 —
|
||||
예전에 멤버였거나 담당자·멘션·협업자로 기록돼 있어도, 지금 권한이 없으면 보이지도
|
||||
바꾸지도 알림을 받지도 않는다(기록 자체는 업무 이력으로 남긴다).
|
||||
|
||||
프로젝트
|
||||
관리(=보기·작업 CRUD) : 관리자(is_admin) · 프로젝트 owner · 배정 멤버. 모두 `project` 모듈 권한이 있어야 한다.
|
||||
|
||||
작업
|
||||
FULL : 원 소속 프로젝트를 관리할 수 있음 → 보기·수정·댓글·첨부·삭제(삭제는 추가로 생성자 규칙)
|
||||
READ : 원 소속 권한은 없지만, 이 작업(또는 상위 작업)이 연결된(멀티호밍) 프로젝트를 관리할 수 있음
|
||||
→ 그 작업의 상세·하위 작업 목록·댓글·첨부 보기만. 원 소속의 다른 작업·멤버는 보이지 않는다.
|
||||
연결된 프로젝트 안에서의 섹션 이동(POST /links, 이미 연결된 경우)은 예전처럼 허용.
|
||||
None : 권한 없음 → 403/목록에서 제외/알림·메일 대상 제외
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Iterable
|
||||
|
||||
from . import store
|
||||
|
||||
FULL = "full"
|
||||
READ = "read"
|
||||
|
||||
UserLookup = Callable[[str], "dict[str, Any] | None"]
|
||||
|
||||
|
||||
def default_user_lookup(email: str) -> dict[str, Any] | None:
|
||||
"""등록 사용자 레코드(app.main.user_store). 지연 import — 테스트는 lookup 을 직접 넘긴다."""
|
||||
from app.main import user_store # noqa: WPS433
|
||||
|
||||
return user_store.get(store.norm_str(email, lower=True))
|
||||
|
||||
|
||||
def _is_admin(user: dict[str, Any] | None) -> bool:
|
||||
from app.store import is_admin # noqa: WPS433
|
||||
|
||||
return is_admin(user)
|
||||
|
||||
|
||||
def can_use_module(user: dict[str, Any] | None) -> bool:
|
||||
from app.store import has_module # noqa: WPS433
|
||||
|
||||
return bool(user) and has_module(user, "project")
|
||||
|
||||
|
||||
def email_of(user: dict[str, Any] | None) -> str:
|
||||
return store.norm_str((user or {}).get("email", ""), lower=True)
|
||||
|
||||
|
||||
def can_manage_project(st: Any, user: dict[str, Any] | None, project_id: Any) -> bool:
|
||||
"""프로젝트 관리(=보기·작업 CRUD) — 관리자 또는 owner/멤버. 모듈 권한이 없으면 False."""
|
||||
if not can_use_module(user):
|
||||
return False
|
||||
if _is_admin(user):
|
||||
return True
|
||||
try:
|
||||
pid = int(project_id)
|
||||
except (TypeError, ValueError):
|
||||
return False
|
||||
return bool(st.is_member(project_id=pid, user_email=email_of(user)))
|
||||
|
||||
|
||||
def visible_project_ids(st: Any, user: dict[str, Any]) -> set[int] | None:
|
||||
"""관리할 수 있는 프로젝트 id 집합. 관리자는 None(=전체)."""
|
||||
if _is_admin(user):
|
||||
return None
|
||||
if not can_use_module(user):
|
||||
return set()
|
||||
return {
|
||||
int(p["id"]) for p in st.list_projects(include_archived=True, member_email=email_of(user))
|
||||
}
|
||||
|
||||
|
||||
def task_access(st: Any, user: dict[str, Any] | None, task: dict[str, Any] | None) -> str | None:
|
||||
"""작업 하나에 대한 지금 권한: FULL / READ / None."""
|
||||
if not task or not can_use_module(user):
|
||||
return None
|
||||
if can_manage_project(st, user, task.get("project_id")):
|
||||
return FULL
|
||||
for pid in link_scope(st, [int(task["id"])]).get(int(task["id"]), set()):
|
||||
if can_manage_project(st, user, pid):
|
||||
return READ
|
||||
return None
|
||||
|
||||
|
||||
def link_scope(st: Any, task_ids: Iterable[int]) -> dict[int, set[int]]:
|
||||
"""작업 id → 이 작업 또는 상위 작업이 연결된 프로젝트 id 들. 연결 표가 없으면 빈 값."""
|
||||
ids = [int(i) for i in task_ids]
|
||||
if not ids:
|
||||
return {}
|
||||
try:
|
||||
return st.task_link_scope(task_ids=ids)
|
||||
except Exception: # noqa: BLE001 - 003 미적용(연결 기능 없음) → 연결로 보이는 작업 없음
|
||||
return {}
|
||||
|
||||
|
||||
def filter_visible_tasks(st: Any, user: dict[str, Any], tasks: list[dict[str, Any]],
|
||||
*, key: str = "id") -> list[dict[str, Any]]:
|
||||
"""목록에서 지금 볼 수 있는(FULL 또는 READ) 작업만 남긴다 — 내 작업·수신함·알림 공용."""
|
||||
allowed = visible_project_ids(st, user)
|
||||
if allowed is None:
|
||||
return list(tasks)
|
||||
ids = [int(t[key]) for t in tasks if t.get(key) is not None]
|
||||
scope = link_scope(st, ids)
|
||||
out = []
|
||||
for t in tasks:
|
||||
tid = t.get(key)
|
||||
pid = t.get("project_id")
|
||||
if pid is not None and int(pid) in allowed:
|
||||
out.append(t)
|
||||
elif tid is not None and scope.get(int(tid), set()) & allowed:
|
||||
out.append(t)
|
||||
return out
|
||||
|
||||
|
||||
def email_task_access(st: Any, email: str, task: dict[str, Any],
|
||||
lookup: UserLookup | None = None) -> str | None:
|
||||
"""이메일(알림·멘션 대상)이 지금 이 작업을 볼 수 있는지. 등록 안 된 사람·모듈 권한 없는 사람은 None."""
|
||||
rec = (lookup or default_user_lookup)(email)
|
||||
if not rec:
|
||||
return None
|
||||
rec = {**rec, "email": rec.get("email") or email}
|
||||
return task_access(st, rec, task)
|
||||
|
||||
|
||||
def filter_recipients(st: Any, task: dict[str, Any], emails: Iterable[str],
|
||||
lookup: UserLookup | None = None) -> list[str]:
|
||||
"""알림·메일·멘션 대상 중 지금 이 작업을 볼 수 있는 사람만(순서 유지, 중복 제거)."""
|
||||
out: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for e in emails:
|
||||
em = store.norm_str(e, lower=True)
|
||||
if not em or em in seen:
|
||||
continue
|
||||
seen.add(em)
|
||||
if email_task_access(st, em, task, lookup) is not None:
|
||||
out.append(em)
|
||||
return out
|
||||
|
||||
|
||||
def can_assign(st: Any, email: str, project_id: Any, lookup: UserLookup | None = None) -> bool:
|
||||
"""담당자·소유자 후보 — 등록된 사용자이고 project 모듈 권한이 있으며, 그 프로젝트를
|
||||
관리할 수 있어야 한다(관리자 포함). 권한 없는 사람에게 작업 정보가 담긴 알림이 가지 않게."""
|
||||
rec = (lookup or default_user_lookup)(email)
|
||||
if not rec:
|
||||
return False
|
||||
rec = {**rec, "email": rec.get("email") or email}
|
||||
return can_manage_project(st, rec, project_id)
|
||||
+137
-5
@@ -100,6 +100,7 @@ class ProjectStore:
|
||||
ic = store.validate_project_icon(icon)
|
||||
sd = store.validate_date(start_date)
|
||||
dd = store.validate_date(due_date)
|
||||
store.validate_date_range(sd, dd)
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
if parent_id is not None:
|
||||
@@ -158,15 +159,26 @@ class ProjectStore:
|
||||
}
|
||||
sets: list[str] = []
|
||||
params: list[Any] = []
|
||||
clean: dict[str, Any] = {}
|
||||
for key, fn in allowed.items():
|
||||
if key in fields:
|
||||
clean[key] = fn(fields[key])
|
||||
sets.append(f"{key} = %s")
|
||||
params.append(fn(fields[key]))
|
||||
params.append(clean[key])
|
||||
if not sets:
|
||||
existing = self.get_project(project_id=project_id)
|
||||
if existing is None:
|
||||
raise KeyError(project_id)
|
||||
return existing
|
||||
if "start_date" in clean or "due_date" in clean:
|
||||
# 한쪽만 바꿔도 기존 값과 합친 최종 상태로 검사한다.
|
||||
existing = self.get_project(project_id=project_id)
|
||||
if existing is None:
|
||||
raise KeyError(project_id)
|
||||
store.validate_date_range(
|
||||
clean["start_date"] if "start_date" in clean else existing.get("start_date"),
|
||||
clean["due_date"] if "due_date" in clean else existing.get("due_date"),
|
||||
)
|
||||
params.append(project_id)
|
||||
with self._pool.connection() as conn:
|
||||
row = conn.execute(
|
||||
@@ -605,7 +617,9 @@ class ProjectStore:
|
||||
dd = store.validate_date(due_date)
|
||||
sti = store.validate_time(start_time)
|
||||
dti = store.validate_time(due_time)
|
||||
store.validate_date_range(sd, dd, sti, dti)
|
||||
assignee = store.norm_str(assignee_email, lower=True)
|
||||
done_at = None
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
if parent_task_id is not None:
|
||||
@@ -636,6 +650,13 @@ class ProjectStore:
|
||||
# 세션이 없어 해당 없음).
|
||||
if not assignee and stage_id is not None:
|
||||
assignee, assignee_name = self._stage_default_assignee(conn, stage_id, project_id)
|
||||
# 완료 섹션에 바로 만든 작업은 완료 섹션으로 옮긴 것과 같이 완료 처리(완료 시각·이력).
|
||||
if stage_id is not None:
|
||||
done_row = conn.execute(
|
||||
"SELECT is_done_stage FROM project_stages WHERE id = %s", (stage_id,)
|
||||
).fetchone()
|
||||
if done_row and done_row["is_done_stage"]:
|
||||
done_at = now_kst()
|
||||
nxt = conn.execute(
|
||||
"SELECT COALESCE(MAX(sort_order), -1) + 1 AS n FROM tasks "
|
||||
"WHERE project_id = %s",
|
||||
@@ -646,21 +667,26 @@ class ProjectStore:
|
||||
INSERT INTO tasks
|
||||
(project_id, stage_id, parent_task_id, title, description,
|
||||
assignee_email, assignee_name, priority, start_date, due_date,
|
||||
start_time, due_time, sort_order, created_by)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
start_time, due_time, sort_order, created_by, completed_at)
|
||||
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
|
||||
RETURNING *
|
||||
""",
|
||||
(
|
||||
project_id, stage_id, parent_task_id, ttl, store.norm_str(description),
|
||||
assignee, store.norm_str(assignee_name), pr, sd, dd,
|
||||
sti, dti, int(nxt["n"]), store.norm_str(created_by, lower=True),
|
||||
sti, dti, int(nxt["n"]), store.norm_str(created_by, lower=True), done_at,
|
||||
),
|
||||
).fetchone()
|
||||
if assignee:
|
||||
self._log(conn, project_id=project_id, task_id=row["id"],
|
||||
actor=created_by, action=store.ACTION_ASSIGNED,
|
||||
detail=f"{ttl} → {assignee}")
|
||||
return self.get_task(task_id=row["id"])
|
||||
if done_at is not None:
|
||||
self._log(conn, project_id=project_id, task_id=row["id"],
|
||||
actor=created_by, action=store.ACTION_COMPLETED, detail=ttl)
|
||||
out = self.get_task(task_id=row["id"])
|
||||
out["_newly_completed"] = done_at is not None
|
||||
return out
|
||||
|
||||
def move_subtask(
|
||||
self, *, task_id: int, parent_task_id: int, actor: str = ""
|
||||
@@ -806,6 +832,15 @@ class ProjectStore:
|
||||
if not sets:
|
||||
return {**prev, "_newly_assigned": None, "_newly_completed": False}
|
||||
|
||||
# 날짜 범위 — 한쪽만 바꾸거나 지워도 기존 값과 합친 최종 상태로 검사.
|
||||
if any(k in fields for k in ("start_date", "due_date", "start_time", "due_time")):
|
||||
def final(key: str, fn: Any) -> Any:
|
||||
return fn(fields[key]) if key in fields else prev.get(key)
|
||||
store.validate_date_range(
|
||||
final("start_date", store.validate_date), final("due_date", store.validate_date),
|
||||
final("start_time", store.validate_time), final("due_time", store.validate_time),
|
||||
)
|
||||
|
||||
params.append(task_id)
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
@@ -1217,6 +1252,51 @@ class ProjectStore:
|
||||
).fetchone()
|
||||
return self._serialize(row)
|
||||
|
||||
def add_comment_with_attachments(
|
||||
self, *, task_id: int, author_email: str, author_name: str, body: str,
|
||||
files: list[dict[str, Any]], parent_id: int | None = None,
|
||||
) -> tuple[dict[str, Any], list[dict[str, Any]]]:
|
||||
"""댓글과 첨부를 한 트랜잭션에 — 둘 중 하나라도 실패하면 아무것도 남지 않는다
|
||||
(첨부 없이 빈 댓글만 남던 문제). files = [{filename, stored_name, content_type, size_bytes}].
|
||||
본문이 비어도 되지만 첨부가 한 개 이상 있어야 한다."""
|
||||
text = store.norm_str(body)
|
||||
if not files and not text:
|
||||
raise ValueError("댓글 내용이 비었습니다.")
|
||||
author = store.norm_str(author_email, lower=True)
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
root = None
|
||||
if parent_id:
|
||||
p = conn.execute(
|
||||
"SELECT id, task_id, parent_id FROM task_comments WHERE id = %s", (parent_id,)
|
||||
).fetchone()
|
||||
if not p or int(p["task_id"]) != int(task_id):
|
||||
raise ValueError("답글을 달 댓글을 찾을 수 없습니다.")
|
||||
root = int(p["parent_id"] or p["id"])
|
||||
if root is not None:
|
||||
row = conn.execute(
|
||||
"INSERT INTO task_comments (task_id, author_email, author_name, body, parent_id) "
|
||||
"VALUES (%s,%s,%s,%s,%s) RETURNING *",
|
||||
(task_id, author, store.norm_str(author_name), text, root),
|
||||
).fetchone()
|
||||
else:
|
||||
row = conn.execute(
|
||||
"INSERT INTO task_comments (task_id, author_email, author_name, body) "
|
||||
"VALUES (%s,%s,%s,%s) RETURNING *",
|
||||
(task_id, author, store.norm_str(author_name), text),
|
||||
).fetchone()
|
||||
atts = []
|
||||
for f in files:
|
||||
atts.append(conn.execute(
|
||||
"INSERT INTO task_attachments "
|
||||
"(task_id, filename, stored_name, content_type, size_bytes, uploaded_by, comment_id) "
|
||||
"VALUES (%s,%s,%s,%s,%s,%s,%s) RETURNING *",
|
||||
(task_id, store.norm_str(f["filename"]), f["stored_name"],
|
||||
store.norm_str(f.get("content_type") or "application/octet-stream"),
|
||||
int(f["size_bytes"]), author, row["id"]),
|
||||
).fetchone())
|
||||
return self._serialize(row), [self._serialize(a) for a in atts]
|
||||
|
||||
def update_comment(
|
||||
self, *, comment_id: int, requester: str, is_admin: bool, body: str
|
||||
) -> dict[str, Any]:
|
||||
@@ -1655,6 +1735,58 @@ class ProjectStore:
|
||||
).fetchall()
|
||||
return [self._serialize(r) for r in rows]
|
||||
|
||||
def add_reminder_notification(
|
||||
self, *, task_id: int, kind: str, due_date: str, recipient_email: str,
|
||||
project_id: int | None, title: str, body: str,
|
||||
) -> bool:
|
||||
"""마감 알림 발송 기록 + 수신함 알림을 한 트랜잭션에. 처음이면 둘 다 넣고 True,
|
||||
이미 보냈으면(UNIQUE) False. 알림 생성이 실패하면 발송 기록도 되돌려져 다음 실행에서
|
||||
다시 시도된다(예전엔 기록만 남아 영영 안 갔다). 동시에 두 번 돌아도 UNIQUE 로 한 번만."""
|
||||
rcpt = store.norm_str(recipient_email, lower=True)
|
||||
with self._pool.connection() as conn:
|
||||
with conn.transaction():
|
||||
row = conn.execute(
|
||||
"INSERT INTO task_reminders (task_id, kind, due_date, recipient_email) "
|
||||
"VALUES (%s,%s,%s,%s) ON CONFLICT DO NOTHING RETURNING id",
|
||||
(task_id, kind, due_date, rcpt),
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return False
|
||||
conn.execute(
|
||||
"INSERT INTO project_notifications "
|
||||
"(recipient_email, actor_email, project_id, task_id, type, title, body) "
|
||||
"VALUES (%s,'',%s,%s,%s,%s,%s)",
|
||||
(rcpt, project_id, task_id, kind, store.norm_str(title), store.norm_str(body)),
|
||||
)
|
||||
return True
|
||||
|
||||
def task_link_scope(self, *, task_ids: list[int]) -> dict[int, set[int]]:
|
||||
"""작업 id → 이 작업 또는 그 상위 작업들이 연결(멀티호밍)된 프로젝트 id 집합.
|
||||
연결된 프로젝트 멤버가 그 작업(과 하위 작업)을 읽기 전용으로 볼 수 있는지 판단한다."""
|
||||
ids = sorted({int(i) for i in task_ids})
|
||||
if not ids:
|
||||
return {}
|
||||
with self._pool.connection() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
WITH RECURSIVE chain AS (
|
||||
SELECT id AS task_id, id AS anc_id, parent_task_id, 0 AS depth
|
||||
FROM tasks WHERE id = ANY(%s)
|
||||
UNION ALL
|
||||
SELECT c.task_id, t.id, t.parent_task_id, c.depth + 1
|
||||
FROM chain c JOIN tasks t ON t.id = c.parent_task_id
|
||||
WHERE c.depth < 20
|
||||
)
|
||||
SELECT c.task_id, l.project_id
|
||||
FROM chain c JOIN task_project_links l ON l.task_id = c.anc_id
|
||||
""",
|
||||
(ids,),
|
||||
).fetchall()
|
||||
out: dict[int, set[int]] = {}
|
||||
for r in rows:
|
||||
out.setdefault(int(r["task_id"]), set()).add(int(r["project_id"]))
|
||||
return out
|
||||
|
||||
def record_reminder(
|
||||
self, *, task_id: int, kind: str, due_date: str, recipient_email: str,
|
||||
) -> bool:
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
· due_today — 오늘 마감
|
||||
· overdue — 마감이 지남(최근 7일 이내 마감분만 — 첫 적용 때 오래된 업무가
|
||||
한꺼번에 쏟아지지 않게, 연휴로 며칠 건너뛰어도 놓치지 않게)
|
||||
수신자는 담당자. 담당자가 없으면 팔로워 전원.
|
||||
수신자는 담당자. 담당자가 없으면 팔로워 전원. 단, 지금 그 작업을 볼 수 있는 사람만.
|
||||
|
||||
중복 방지: task_reminders(업무, 종류, 마감일, 수신자) UNIQUE — 같은 알림은 한 번만
|
||||
간다(재기동·여러 번 실행해도 안전). 마감일을 바꾸면 새 마감일 기준으로 다시 알린다.
|
||||
발송 기록과 수신함 알림은 한 트랜잭션이라, 알림 생성이 실패하면 다음 실행에 다시 시도된다.
|
||||
|
||||
실행 방식: 웹 프로세스 안의 데몬 스레드(start_reminder_thread). 5분마다 깨어나
|
||||
"오늘 아직 안 돌았고, 설정 시각이 지났고, 영업일이면" 한 번 돈다. 여러 프로세스가
|
||||
@@ -33,7 +34,7 @@ from typing import Any
|
||||
|
||||
from app.timezone import now_kst
|
||||
|
||||
from . import store
|
||||
from . import access, store
|
||||
|
||||
logger = logging.getLogger("project.reminders")
|
||||
|
||||
@@ -87,8 +88,18 @@ def _title_for(kind: str, task: dict[str, Any], today: date) -> str:
|
||||
return f"마감 지남({(today - due).days}일): {task['title']}"
|
||||
|
||||
|
||||
def run_due_reminders(st: Any, *, today: date | None = None) -> dict[str, int]:
|
||||
"""한 번 실행. 새로 만든 알림 수를 종류별로 돌려준다."""
|
||||
def run_due_reminders(
|
||||
st: Any, *, today: date | None = None, lookup: access.UserLookup | None = None,
|
||||
) -> dict[str, int]:
|
||||
"""한 번 실행. 새로 만든 알림 수를 종류별로 돌려준다.
|
||||
|
||||
- 수신자는 지금 그 작업을 볼 수 있는 사람만(access.filter_recipients) — 멤버에서 빠진 담당자·
|
||||
협업자, 모듈 권한이 없어진 직원에게는 수신함 알림도 메일도 가지 않는다.
|
||||
- 발송 기록(task_reminders)과 수신함 알림은 한 트랜잭션(add_reminder_notification) — 알림 생성이
|
||||
실패하면 기록도 되돌려져 다음 실행에서 다시 시도된다. 같은 알림은 UNIQUE 로 한 번만(동시 실행 포함).
|
||||
- 보장 범위: 수신함 알림까지. 메일(PROJECT_REMINDER_EMAIL)은 알림이 새로 만들어진 것만 요약해 한 번
|
||||
보내며, 메일 발송 실패는 재시도하지 않는다(수신함 알림은 이미 남아 있다).
|
||||
"""
|
||||
today = today or now_kst().date()
|
||||
start = today - timedelta(days=OVERDUE_WINDOW_DAYS)
|
||||
end = next_workday(today)
|
||||
@@ -101,22 +112,25 @@ def run_due_reminders(st: Any, *, today: date | None = None) -> dict[str, int]:
|
||||
if kind is None:
|
||||
continue
|
||||
assignee = store.norm_str(t.get("assignee_email"), lower=True)
|
||||
recipients = [assignee] if assignee else store.normalize_emails(t.get("followers") or [])
|
||||
wanted = [assignee] if assignee else store.normalize_emails(t.get("followers") or [])
|
||||
try:
|
||||
recipients = access.filter_recipients(st, t, wanted, lookup)
|
||||
except Exception: # noqa: BLE001 - 권한 확인이 안 되면 이번엔 보내지 않는다(다음 실행에 재시도)
|
||||
logger.warning("마감 알림 수신자 확인 실패: task=%s", t["id"])
|
||||
continue
|
||||
for rcpt in recipients:
|
||||
if not st.record_reminder(
|
||||
task_id=t["id"], kind=kind, due_date=t["due_date"][:10], recipient_email=rcpt,
|
||||
):
|
||||
continue # 이미 보냄
|
||||
title = _title_for(kind, t, today)
|
||||
try:
|
||||
st.add_notification(
|
||||
recipient_email=rcpt, actor_email="", project_id=t["project_id"],
|
||||
task_id=t["id"], type=kind, title=title,
|
||||
created = st.add_reminder_notification(
|
||||
task_id=t["id"], kind=kind, due_date=t["due_date"][:10], recipient_email=rcpt,
|
||||
project_id=t["project_id"], title=title,
|
||||
body=f"{t.get('project_name') or ''} · 마감 {t['due_date'][:10]}",
|
||||
)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.warning("마감 알림 생성 실패: task=%s", t["id"])
|
||||
except Exception: # noqa: BLE001 - 기록도 되돌려졌으니 다음 실행에서 다시 시도
|
||||
logger.warning("마감 알림 생성 실패(다음 실행에 재시도): task=%s", t["id"])
|
||||
continue
|
||||
if not created:
|
||||
continue # 이미 보냄
|
||||
counts[kind] += 1
|
||||
digest.setdefault(rcpt, []).append((title, t))
|
||||
|
||||
|
||||
+486
-172
File diff suppressed because it is too large
Load Diff
@@ -313,6 +313,30 @@ def validate_date(d: Any) -> str | None:
|
||||
return v[:10]
|
||||
|
||||
|
||||
DATE_RANGE_ERROR = "시작일이 마감일보다 늦을 수 없습니다."
|
||||
TIME_RANGE_ERROR = "같은 날이면 시작 시각이 마감 시각보다 늦을 수 없습니다."
|
||||
|
||||
|
||||
def validate_date_range(
|
||||
start_date: Any, due_date: Any, start_time: Any = None, due_time: Any = None
|
||||
) -> None:
|
||||
"""최종 상태(부분 수정이면 기존 값 + 바꾼 값)의 날짜 범위 검사 — 프로젝트·작업 공용.
|
||||
|
||||
둘 다 있으면 start_date <= due_date. 같은 날이고 두 시각이 모두 있으면 start_time <= due_time.
|
||||
한쪽이 비어 있는 입력은 허용. 값 형식 오류는 validate_date/validate_time 이 먼저 낸다.
|
||||
"""
|
||||
sd = validate_date(start_date)
|
||||
dd = validate_date(due_date)
|
||||
if sd and dd:
|
||||
if sd > dd:
|
||||
raise ValueError(DATE_RANGE_ERROR)
|
||||
if sd == dd:
|
||||
st = validate_time(start_time)
|
||||
dt = validate_time(due_time)
|
||||
if st and dt and st > dt:
|
||||
raise ValueError(TIME_RANGE_ERROR)
|
||||
|
||||
|
||||
def validate_time(t: Any) -> str | None:
|
||||
"""'HH:MM' 형식만 통과(초는 버림). 빈값/None 은 None(=종일)."""
|
||||
v = norm_str(t)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -169,5 +169,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930f" defer></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20260926v" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
@@ -119,7 +119,9 @@
|
||||
<tr><td>작업·섹션·프로젝트 삭제</td><td><b>만든 사람만</b> 지울 수 있습니다(최고 관리자는 예외).</td></tr>
|
||||
<tr><td>댓글 고치기·지우기</td><td>댓글을 쓴 사람(또는 관리자)만.</td></tr>
|
||||
<tr><td>새 프로젝트, 프로젝트 수정·순서 바꾸기</td><td>관리자 (<span class="pjh-ui">+</span> · <span class="pjh-ui">✎</span> · <span class="pjh-ui">⣿</span> 버튼이 관리자에게만 보입니다)</td></tr>
|
||||
<tr><td>멤버 배정·제외</td><td>관리자</td></tr>
|
||||
<tr><td>멤버 배정·제외, 프로젝트 소유자 바꾸기</td><td>관리자</td></tr>
|
||||
<tr><td>다른 프로젝트에서 연결돼 온 작업</td><td>원래 프로젝트 멤버가 아니면 <b>읽기만</b> — 내용·댓글·첨부는 보이지만 고치거나 댓글을 달 수 없습니다(연결된 보드 안에서 섹션 옮기기는 됩니다).</td></tr>
|
||||
<tr><td>멤버에서 빠졌을 때</td><td>그 프로젝트의 작업은 내 작업·수신함·알림·검색에서 사라지고, 예전 링크로도 열리지 않습니다. 새 알림도 오지 않습니다.</td></tr>
|
||||
<tr><td>휴지통 보기·복구, 전체 멤버, 대시보드의 담당자별 차트</td><td>관리자</td></tr>
|
||||
<tr><td>목표 보기</td><td>누구나 · <b>목표 입력·연도 추가·업무 영역 편집</b>은 관리자</td></tr>
|
||||
</table>
|
||||
@@ -263,7 +265,7 @@
|
||||
<tr><td><span class="pjh-ui"><span class="material-symbols-outlined">link</span>공유</span></td><td>이 작업의 주소를 복사합니다. 메신저로 보내면 받은 멤버가 바로 이 작업을 엽니다.</td></tr>
|
||||
<tr><td><span class="pjh-ui">✓ 완료로 표시</span></td><td>작업을 완료합니다. 다시 누르면 <span class="pjh-ui">↩ 완료 취소</span>.</td></tr>
|
||||
<tr><td><span class="pjh-ui">삭제</span></td><td>작업을 지웁니다(만든 사람만). 하위 작업이 있으면 함께 지울지 한 번 더 묻습니다. 지운 작업은 휴지통에 3개월 보관됩니다.</td></tr>
|
||||
<tr><td><span class="pjh-ui">저장됨</span></td><td>저장 버튼이 없습니다 — 고치는 즉시 저장되고, 버튼 줄 오른쪽에 <span class="pjh-ui">저장 중…</span> → <span class="pjh-ui">✓ 저장됨</span>이 잠깐 보입니다.</td></tr>
|
||||
<tr><td><span class="pjh-ui">저장됨</span></td><td>저장 버튼이 없습니다 — 고치는 즉시 저장되고, 버튼 줄 오른쪽에 <span class="pjh-ui">저장 중…</span> → <span class="pjh-ui">✓ 저장됨</span>이 잠깐 보입니다. 저장이 안 되면 <span class="pjh-ui">저장 실패 · 다시 시도</span>(눌러서 다시 저장)가 뜨고, 이 상태로 창을 닫거나 다른 작업을 열면 한 번 더 저장해 본 뒤 <b>버리고 넘어갈지 / 계속 편집할지</b> 묻습니다 — 모른 채 내용이 사라지지 않습니다. 이미지를 올리는 중이면 다 올라갈 때까지 기다렸다가 넘어갑니다.</td></tr>
|
||||
</table>
|
||||
<div class="pjh-note"><span class="material-symbols-outlined">info</span>
|
||||
<div><b>실시간 저장</b> — 제목은 칸을 벗어나거나 <kbd>Enter</kbd>, 설명은 입력을 멈추고 1초쯤 뒤(또는 칸을 벗어날 때), 담당자·섹션·우선순위·마감일은 바꾸는 즉시 저장됩니다. 새 작업은 <b>제목을 쓰는 순간</b> 만들어집니다(제목 없이 닫으면 만들어지지 않습니다). 협업자 · 하위 작업 · 첨부 파일 · 다른 프로젝트 추가 · 댓글도 누르는 즉시 저장됩니다.</div></div>
|
||||
@@ -301,7 +303,8 @@
|
||||
</ol>
|
||||
<p>작업은 하나라서 어느 보드에서 고쳐도 모두 같이 바뀝니다.</p>
|
||||
<h3>댓글</h3>
|
||||
<p>작업 창 맨 아래에 항상 고정된 댓글 칸에 쓰고 <kbd>Enter</kbd>(스크롤해도 그 자리에 있습니다). 칸 오른쪽 <span class="pjh-ui">☺</span>는 이모티콘, <span class="pjh-ui">@</span>는 멤버 태그입니다. 답글은 원 댓글 아래 들여 쓰여 <span class="pjh-ui">↳</span> 표시와 함께 보입니다. 내가 쓴 댓글은 <span class="pjh-ui">✎</span>로 고치고 <span class="pjh-ui">×</span>로 지웁니다. 댓글 속 웹 주소는 링크가 됩니다.</p>
|
||||
<p>작업 창 맨 아래에 항상 고정된 댓글 칸에 쓰고 <kbd>Enter</kbd>(스크롤해도 그 자리에 있습니다). 칸 오른쪽 <span class="pjh-ui">☺</span>는 이모티콘, <span class="pjh-ui">@</span>는 멤버 태그입니다. 답글은 원 댓글 아래 들여 쓰여 <span class="pjh-ui">↳</span> 표시와 함께 보입니다. 내가 쓴 댓글은 <span class="pjh-ui">✎</span>로 고치고 <span class="pjh-ui">×</span>로 지웁니다. 댓글 속 웹 주소는 링크가 됩니다. 댓글에 붙인 파일은 그 댓글 아래에 보이고(파일만 보낸 댓글도), 첨부 파일 목록에는 <span class="pjh-ui">댓글</span> 표시가 붙습니다.</p>
|
||||
<p>댓글 대화창에서 파일을 보낼 때 보낼 수 없는 파일(빈 파일, 20MB 초과)이 있으면 댓글을 만들지 않고 그 파일만 빨갛게 표시합니다 — 빼고 다시 보내세요. 인터넷이 끊겨도 쓴 내용과 파일은 그대로 남아 다시 보낼 수 있고, 같은 댓글이 두 번 올라가지 않습니다. @태그는 이 작업을 볼 수 있는 사람만 고를 수 있습니다. 한글을 입력하는 중(조합 중)의 <kbd>Enter</kbd>는 글자 확정만 하고 보내지 않습니다.</p>
|
||||
</section>
|
||||
|
||||
<!-- 9. 작업 창의 하위 작업 -->
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -104,5 +104,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930f" defer></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20260930f" defer></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -265,6 +265,11 @@
|
||||
<span class="pj-t-parent-title" id="pj-t-parent-title"></span>
|
||||
</button>
|
||||
<textarea id="pj-t-title" class="pj-t-title-input" rows="1" placeholder="작업 제목"></textarea>
|
||||
<!-- 다른 프로젝트에서 연결돼 온 작업을 원 소속 권한 없이 열었을 때 — 보기만 된다(서버도 변경 거절). -->
|
||||
<div class="pj-readonly-note" id="pj-t-readonly" hidden>
|
||||
<span class="material-symbols-outlined">visibility</span>
|
||||
<span>다른 프로젝트(<b id="pj-t-readonly-home"></b>)에서 연결된 작업이라 읽기만 할 수 있습니다. 변경은 원 소속 프로젝트 멤버만 할 수 있습니다.</span>
|
||||
</div>
|
||||
|
||||
<div class="pj-modal-body">
|
||||
<div class="pj-modal-col-main">
|
||||
@@ -491,5 +496,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20260930f" defer></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930f" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260930g" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260930f" defer></script>
|
||||
<script src="/static/project.js?v=20260930g" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2116,3 +2116,44 @@ textarea.pj-goal-text::placeholder { color: rgba(0, 0, 0, .3); }
|
||||
width: 16px; height: 16px; border: 1px solid rgba(0, 0, 0, .2); border-radius: 4px; background:
|
||||
linear-gradient(to top right, transparent calc(50% - 1px), #e5484d calc(50% - 1px), #e5484d calc(50% + 1px), transparent calc(50% + 1px));
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════════════════════════════
|
||||
권한·저장 안전장치(2026-09-30)
|
||||
════════════════════════════════════════════════════════════ */
|
||||
/* 읽기 전용 안내줄 — 다른 프로젝트에서 연결돼 온 작업(원 소속 권한 없음) */
|
||||
.pj-readonly-note {
|
||||
display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; padding: 7px 10px;
|
||||
border-radius: 8px; background: #f1f5fb; color: #34507a; font-size: 12.5px; line-height: 1.4;
|
||||
}
|
||||
.pj-readonly-note[hidden] { display: none; }
|
||||
.pj-readonly-note .material-symbols-outlined { font-size: 17px; }
|
||||
.pj-modal.is-readonly .pj-t-title-input { cursor: default; }
|
||||
.pj-modal.is-readonly .pj-desc-editor { background: #fafbfc; }
|
||||
.pj-subtask-row.is-readonly .pj-subtask-check,
|
||||
.pj-subtask-row.is-readonly .pj-subtask-due,
|
||||
.pj-subtask-row.is-readonly .pj-subtask-av { cursor: default; opacity: .7; }
|
||||
/* 이 프로젝트 권한을 잃었을 때 화면 위 안내 */
|
||||
.pj-access-lost {
|
||||
margin: 0 0 10px; padding: 10px 14px; border-radius: 8px; background: #fdecea; color: #a1261b;
|
||||
font-size: 13px; font-weight: 600;
|
||||
}
|
||||
.pj-access-lost a { color: inherit; text-decoration: underline; margin-left: 6px; }
|
||||
/* 저장 실패 — 눌러서 다시 시도 */
|
||||
.pj-autosave-state.is-retry { cursor: pointer; text-decoration: underline dotted; }
|
||||
/* 작업 창 댓글의 첨부(파일만 있는 댓글도 보이게) */
|
||||
.pj-comment-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
|
||||
.pj-comment-att { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; color: var(--pj-ink); }
|
||||
.pj-comment-att-file {
|
||||
padding: 4px 8px; border: 1px solid var(--pj-border); border-radius: 6px; background: #fff; font-size: 12.5px;
|
||||
}
|
||||
.pj-comment-att-file:hover { background: #f6f7f8; }
|
||||
.pj-comment-att-img img {
|
||||
display: block; max-width: 160px; max-height: 120px; border-radius: 6px; border: 1px solid var(--pj-border);
|
||||
object-fit: cover;
|
||||
}
|
||||
/* 첨부 파일 목록에서 댓글에 붙은 파일 표시 */
|
||||
.pj-attach-from-comment {
|
||||
margin-left: 6px; padding: 0 6px; border-radius: 999px; background: #eef0f2; color: #525860; font-size: 11px;
|
||||
}
|
||||
/* 댓글 대화창 — 보낼 수 없었던 파일(빈 파일·20MB 초과) */
|
||||
.pj-chat-pending-chip.is-failed { border-color: #e5484d; background: #fdecea; color: #a1261b; }
|
||||
|
||||
+634
-139
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user