feat(project): weekly meetings editable by anyone, admin completes to lock
Meeting write APIs now accept any project user; deleting a meeting and the
new POST /api/goals/meetings/{week}/complete (complete/reopen) stay admin
only. A completed meeting (migration 022: completed_at, completed_by)
rejects edits with 409; last-week result fields follow the next meeting's
lock instead. The page shows a complete button / locked badge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ const ROOT = path.join(__dirname, "..", "..");
|
||||
const OUT = path.join(__dirname, ".out");
|
||||
const JS = fs.readFileSync(path.join(ROOT, "app", "static", "project.js"), "utf8");
|
||||
const PAGE = {};
|
||||
["goals_admin", "goals_ro", "goals_weekly_admin", "meeting_admin", "meeting_err", "meeting_ro"].forEach(function (n) {
|
||||
["goals_admin", "goals_ro", "goals_weekly_admin", "meeting_admin", "meeting_err", "meeting_ro", "meeting_member"].forEach(function (n) {
|
||||
PAGE[n] = fs.readFileSync(path.join(OUT, n + ".html"), "utf8");
|
||||
});
|
||||
const GOALS_URL = "http://localhost/project/goals/2026";
|
||||
@@ -532,6 +532,31 @@ function meetServer(env, st) {
|
||||
check("[2g] 적용 전 줄 × → 줄만 지움", d.querySelectorAll("#pj-meet-quick tbody tr").length === n - 1 && env.calls.length === calls);
|
||||
}, { notifyOnFail: true });
|
||||
|
||||
// ════════════════════ [2h] 회의록은 누구나 수정 · [회의 완료](관리자)면 잠금 ════════════════════
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.meeting_member, MEET_URL);
|
||||
const st = meetServer(env);
|
||||
await boot(env);
|
||||
const d = env.d;
|
||||
check("[2h] 직원도 회의록 입력칸·메모 편집", !!d.querySelector(".pj-meet-text") && !!d.getElementById("pj-meet-notes"));
|
||||
check("[2h] 직원에겐 삭제·회의 완료 버튼 없음", !d.getElementById("pj-meet-del") && !d.getElementById("pj-meet-complete"));
|
||||
const ta = d.querySelector('tr[data-item="1"] .pj-meet-text');
|
||||
ta.focus(); type(env, ta, "직원이 적은 업무"); ta.blur(); await settle(); await wait(10); await settle();
|
||||
check("[2h] 직원 입력 저장", st.items[1] && st.items[1].content === "직원이 적은 업무", st.items[1]);
|
||||
});
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
|
||||
meetServer(env);
|
||||
let posted = null;
|
||||
env.route("POST", /\/project\/api\/goals\/meetings\/2026-09-28\/complete$/, function (u, body) { posted = body; return { body: { ok: true, completed: true } }; });
|
||||
env.w.erpConfirm = function () { return Promise.resolve(true); };
|
||||
await boot(env);
|
||||
env.d.getElementById("pj-meet-complete").click(); await settle(); await wait(10); await settle();
|
||||
check("[2h] 관리자 [회의 완료] → 완료 요청·새로고침", posted && posted.done === true && env.navigations === 1, [posted, env.navigations]);
|
||||
const ro = makeEnv(PAGE.meeting_ro, MEET_URL); meetServer(ro); await boot(ro);
|
||||
check("[2h] 완료된 회의록 — 입력칸 없음·완료 표시", !ro.d.querySelector(".pj-meet-text, #pj-meet-notes") && /회의 완료/.test(ro.d.querySelector(".pj-meet-done-badge").textContent));
|
||||
});
|
||||
|
||||
// ════════════════════ [3] 목표 표 — 글 저장 실패면 구조 변경·표 교체 중단 ════════════════════
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { promptAnswer: "새 영역" });
|
||||
|
||||
@@ -103,7 +103,7 @@ def meeting_view(err: bool) -> dict:
|
||||
|
||||
def meeting_ctx(admin: bool, err: bool, can_sync: bool = True) -> dict:
|
||||
view = meeting_view(err)
|
||||
return {
|
||||
ctx = {
|
||||
"user": {"email": ME, "is_super_admin": False}, "is_admin": admin, "nav_projects": [], "goal_years": [2026],
|
||||
"goal_year_active": 2026, "my_open_total": 0, "mention_unread": 0, "color_palette": ["#4573d2"],
|
||||
"project_icons": ["folder"], "goal_year": 2026, "goal_month": 9, "meetings_enabled": True,
|
||||
@@ -114,6 +114,16 @@ def meeting_ctx(admin: bool, err: bool, can_sync: bool = True) -> dict:
|
||||
"can_sync": can_sync, "meeting_status": store.MEETING_STATUS, "meet_members": [], "month_plan": None,
|
||||
"attendee_list": [], **copy.deepcopy(view),
|
||||
}
|
||||
# 회의록은 누구나 고친다(2026-10-07) — 보기 전용은 "회의 완료"된 회의록뿐. 관리자 아닌 화면 = 완료된 회의록으로 시험
|
||||
ctx["meeting"].update(can_complete=True, completed=not admin, completed_at="2026-10-02 18:00" if not admin else "",
|
||||
completed_by="admin@test.local" if not admin else "")
|
||||
return ctx
|
||||
|
||||
|
||||
def member_ctx() -> dict:
|
||||
ctx = meeting_ctx(False, False, can_sync=False)
|
||||
ctx["meeting"].update(completed=False, completed_at="", completed_by="")
|
||||
return ctx
|
||||
|
||||
|
||||
def meeting_layout_ctx(admin: bool) -> dict:
|
||||
@@ -156,6 +166,8 @@ def main() -> None:
|
||||
"meeting_admin.html": ("project/goal_meeting.html", meeting_ctx(True, False)),
|
||||
"meeting_err.html": ("project/goal_meeting.html", meeting_ctx(True, True)),
|
||||
"meeting_ro.html": ("project/goal_meeting.html", meeting_ctx(False, False, can_sync=False)),
|
||||
# 관리자 아닌 직원 + 아직 완료 전 회의록 — 누구나 고친다(2026-10-07)
|
||||
"meeting_member.html": ("project/goal_meeting.html", member_ctx()),
|
||||
"meeting_layout_admin.html": ("project/goal_meeting.html", meeting_layout_ctx(True)),
|
||||
"meeting_layout_ro.html": ("project/goal_meeting.html", meeting_layout_ctx(False)),
|
||||
"meeting_merged.html": ("project/goal_meeting.html", meeting_merged_ctx()),
|
||||
|
||||
@@ -196,9 +196,6 @@ class MeetingCellTests(unittest.TestCase):
|
||||
endpoints = [("POST", "/meeting-cells/move", self.payload),
|
||||
("POST", "/meeting-cells/merge", dict(item_from=1, item_to=2)),
|
||||
("DELETE", "/meeting-items/1/cell-merge", None)]
|
||||
with patch.object(api, "_require_user", return_value=dict(role="user", email="user@test.local")):
|
||||
for method, endpoint, body in endpoints:
|
||||
self.assertEqual(client.request(method, "/project/api/goals" + endpoint, json=body).status_code, 403)
|
||||
with patch.object(api, "_require_user", return_value=dict(role="admin", email="admin@test.local")):
|
||||
url = "/project/api/goals/meeting-cells/move"
|
||||
self.assertEqual(client.post(url, json={}).status_code, 400)
|
||||
@@ -207,6 +204,10 @@ class MeetingCellTests(unittest.TestCase):
|
||||
self.st._meeting_cells = lambda conn: False
|
||||
self.assertEqual(client.post("/project/api/goals/meeting-cells/merge", json=dict(item_from=1, item_to=2)).status_code, 503)
|
||||
self.assertEqual(client.post(url, json=self.payload).status_code, 200, "Move/formatting work without 019")
|
||||
# 회의록은 누구나 고친다(2026-10-07) — 관리자가 아니어도 셀 이동·병합·해제를 막지 않는다(잠금은 회의 완료로)
|
||||
with patch.object(api, "_require_user", return_value=dict(role="user", email="user@test.local")):
|
||||
for method, endpoint, body in endpoints:
|
||||
self.assertNotEqual(client.request(method, "/project/api/goals" + endpoint, json=body).status_code, 403)
|
||||
|
||||
def test_amount_cells_accept_text_after_021_and_result_note_reaches_store(self):
|
||||
"""정량 목표·결과 — 숫자면 원 정수 칸, 글(예: 20개)이면 글 칸(021). 지난주 결과 글(result_note, 020)은 API 를 거쳐 저장된다."""
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
"""주간 회의록 — 누구나 수정, 회의 완료(022)면 잠금. 지난주 결과는 다음 주 회의록이 열려 있는 동안만. DB 없이."""
|
||||
import importlib
|
||||
import unittest
|
||||
from contextlib import contextmanager
|
||||
from datetime import date
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.modules.project import store
|
||||
from app.modules.project.db import ProjectStore
|
||||
from tests.test_project_meeting_cells import Connection
|
||||
|
||||
api = importlib.import_module("app.modules.project.router")
|
||||
|
||||
|
||||
class LockConnection(Connection):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.completed = set() # 완료된 주차 시작일
|
||||
|
||||
def execute(self, sql, params=()):
|
||||
if sql.startswith("SELECT completed_at FROM goal_meetings WHERE week_start = %s"):
|
||||
from tests.test_project_meeting_cells import Result
|
||||
return Result([{"completed_at": "done" if params[0] in self.completed else None}])
|
||||
return super().execute(sql, params)
|
||||
|
||||
|
||||
class MeetingLockTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.conn = LockConnection()
|
||||
|
||||
@contextmanager
|
||||
def connection():
|
||||
yield self.conn
|
||||
|
||||
self.st = ProjectStore.__new__(ProjectStore)
|
||||
self.st._pool = SimpleNamespace(connection=connection)
|
||||
self.st._table_exists = lambda conn, name: True
|
||||
self.st._column_exists = lambda conn, table, col: col in {"content_row_span", "completed_at", "result_note"}
|
||||
for r in self.conn.rows.values():
|
||||
r["result_note"] = ""
|
||||
|
||||
def test_completed_meeting_rejects_edits(self):
|
||||
self.conn.completed.add(date(2026, 9, 28))
|
||||
with self.assertRaises(store.MeetingLocked):
|
||||
self.st.update_meeting_item(item_id=1, fields={"content": "x"})
|
||||
with self.assertRaises(store.MeetingLocked):
|
||||
self.st.move_meeting_item(item_id=2, direction=1)
|
||||
|
||||
def test_last_week_result_follows_next_meeting(self):
|
||||
# 9/28 주차(9/28~9/30)가 완료돼도 다음 주차(10/1) 회의록이 열려 있으면 결과는 적을 수 있다
|
||||
self.conn.completed.add(date(2026, 9, 28))
|
||||
out = self.st.update_meeting_item(item_id=1, fields={"result_note": "잘 됨", "result_amount": "100"})
|
||||
self.assertEqual((out["result_note"], out["result_amount"]), ("잘 됨", 100))
|
||||
self.conn.completed.add(date(2026, 10, 1))
|
||||
with self.assertRaises(store.MeetingLocked):
|
||||
self.st.update_meeting_item(item_id=1, fields={"result_note": "늦게"})
|
||||
|
||||
def test_anyone_edits_but_only_admin_completes(self):
|
||||
app = FastAPI()
|
||||
app.include_router(api.router)
|
||||
app.state.project_store = self.st
|
||||
client = TestClient(app)
|
||||
member = dict(role="user", email="member@test.local")
|
||||
with patch.object(api, "_require_user", return_value=member):
|
||||
r = client.put("/project/api/goals/meeting-items/1", json={"content": "누구나"})
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
self.assertEqual(client.post("/project/api/goals/meetings/2026-09-28/complete", json={"done": True}).status_code, 403)
|
||||
self.conn.completed.add(date(2026, 9, 28))
|
||||
r = client.put("/project/api/goals/meeting-items/1", json={"content": "잠김"})
|
||||
self.assertEqual(r.status_code, 409, r.text)
|
||||
self.assertIn("회의가 완료", r.json()["detail"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -747,7 +747,8 @@ def test_goal_meetings():
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
assert req("POST", f"/project/api/goals/meetings/{w1}", BOB, json={"year": w1.year}).status_code == 403
|
||||
# 회의 완료(잠금)는 관리자만 — 회의록 만들기·고치기는 누구나(2026-10-07)
|
||||
assert req("POST", f"/project/api/goals/meetings/{w1}/complete", BOB, json={"done": True}).status_code == 403
|
||||
assert req("POST", f"/project/api/goals/meetings/{w1 + timedelta(days=1)}", ADMIN, json={}).status_code == 400
|
||||
r = req("POST", f"/project/api/goals/meetings/{w1}", ADMIN, json={"year": w1.year})
|
||||
assert r.status_code == 201 and r.json()["created"] is True, r.text
|
||||
@@ -771,7 +772,7 @@ def test_goal_meetings():
|
||||
assert r.status_code == 400
|
||||
assert put(coupang["id"], {"target_amount": "1,200만"}).json()["item"]["target_amount"] == 12_000_000
|
||||
assert put(coupang["id"], {"status": "bogus"}).status_code == 400
|
||||
assert put(coupang["id"], {"content": "x"}, BOB).status_code == 403
|
||||
assert put(coupang["id"], {"content": "추석 타임딜"}, BOB).status_code == 200 # 누구나 수정
|
||||
assert req("PUT", f"/project/api/goals/meetings/{w1}", ADMIN,
|
||||
json={"week_target": "3천만", "attendees": "대표", "notes": "메모"}).status_code == 200
|
||||
# 다음 주 — 줄을 이어받고 전주 칸(prev)에 지난주 할 일·목표
|
||||
@@ -781,6 +782,14 @@ def test_goal_meetings():
|
||||
c2 = next(it for it in m2["items"] if it["carry_from"] == coupang["id"])
|
||||
assert c2["prev"]["content"] == "추석 타임딜" and c2["prev"]["target_amount"] == 12_000_000
|
||||
assert m2["prev_meeting"] == {"week_start": w1.isoformat(), "week_target": 30_000_000}
|
||||
# 회의 완료(022) — w1 을 잠그면 w1 의 주요 업무는 못 고치지만, 지난주 결과는 다음 주(w2)가 열려 있으니 적을 수 있다
|
||||
r = req("POST", f"/project/api/goals/meetings/{w1}/complete", ADMIN, json={"done": True})
|
||||
if r.status_code == 200:
|
||||
assert put(coupang["id"], {"content": "잠김"}, BOB).status_code == 409
|
||||
assert put(coupang["id"], {"result_amount": "100"}, BOB).status_code == 200
|
||||
assert req("POST", f"/project/api/goals/meetings/{w1}/complete", ADMIN, json={"done": False}).json()["completed"] is False
|
||||
else:
|
||||
assert r.status_code == 503, r.text # 022 미적용
|
||||
# 지난주 결과·평가는 지난 회의록 줄에 저장
|
||||
assert put(coupang["id"], {"result_amount": "1.5억", "status": "done"}).json()["item"]["result_amount"] == 150_000_000
|
||||
# 줄 추가(기준 줄 아래)·이동(같은 구역 안)·삭제, 새 구역
|
||||
|
||||
Reference in New Issue
Block a user