feat(프로젝트): 매일 하는 업무 — 날짜 팝업 [매일]·반복 아이콘·시각별 알림
- 마이그레이션 033 tasks.repeat_daily — [매일]이면 마감일·시각 비움, 마감일을 고르면 꺼짐(미적용이면 버튼 숨김·PUT 503) - 마감 칸(카드·목록·내 업무·세부 업무·업무 창)에 반복 아이콘 + "매일" - reminders.run_daily_alerts: 영업일, Project 옵션 daily_alert_times 중 지난 가장 늦은 시각마다 담당자(없으면 협업자)에게 type=daily 알림(task_reminders 로 중복 방지, 데몬 1분 주기) - 큰 알림 팝업·PC 알림 프로그램에서 매일 업무 줄은 노란 배경 - Project 옵션 "알림" 분류: 알림 시각 여러 개 추가·삭제(최대 12) - 도움말·모듈 CLAUDE.md·DEPLOYMENT(033) 갱신, 테스트 추가 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
"""매일 하는 업무(033 tasks.repeat_daily) 알림 — 시각 고르기·수신자·중복. DB 없이 가짜 저장소로.
|
||||
|
||||
실제 DB(열·update_task 규칙)는 tests/test_project_module.py test_repeat_daily_* 가 본다.
|
||||
"""
|
||||
import importlib
|
||||
import unittest
|
||||
from datetime import date
|
||||
from unittest.mock import patch
|
||||
|
||||
rem = importlib.import_module("app.modules.project.reminders")
|
||||
|
||||
|
||||
class FakeStore:
|
||||
def __init__(self, tasks):
|
||||
self.tasks = tasks
|
||||
self.sent = set()
|
||||
self.made = []
|
||||
|
||||
def list_open_daily_tasks(self):
|
||||
return list(self.tasks)
|
||||
|
||||
def add_reminder_notification(self, **kw):
|
||||
key = (kw["task_id"], kw["kind"], kw["due_date"], kw["recipient_email"])
|
||||
if key in self.sent:
|
||||
return False
|
||||
self.sent.add(key)
|
||||
self.made.append(kw)
|
||||
return True
|
||||
|
||||
|
||||
def _visible(st, task, wanted, lookup=None):
|
||||
return [e for e in wanted if e != "gone@x.kr"] # 권한 잃은 사람은 뺀다
|
||||
|
||||
|
||||
class DailyAlertTests(unittest.TestCase):
|
||||
def test_slot_is_latest_passed_time(self):
|
||||
self.assertIsNone(rem.daily_slot(["09:00", "14:00"], "08:59"))
|
||||
self.assertEqual(rem.daily_slot(["09:00", "14:00"], "09:00"), "09:00")
|
||||
self.assertEqual(rem.daily_slot(["09:00", "14:00"], "23:59"), "14:00")
|
||||
self.assertIsNone(rem.daily_slot([], "12:00"))
|
||||
|
||||
def test_assignee_else_followers_once_per_slot(self):
|
||||
st = FakeStore([
|
||||
{"id": 1, "title": "청소", "assignee_email": "A@x.kr", "followers": ["b@x.kr"], "project_id": 7, "project_name": "P"},
|
||||
{"id": 2, "title": "보고", "assignee_email": "", "followers": ["b@x.kr", "gone@x.kr"], "project_id": 7},
|
||||
])
|
||||
with patch.object(rem.access, "filter_recipients", side_effect=_visible):
|
||||
self.assertEqual(rem.run_daily_alerts(st, today=date(2026, 11, 11), slot="09:00"), 2)
|
||||
self.assertEqual(rem.run_daily_alerts(st, today=date(2026, 11, 11), slot="09:00"), 0) # 같은 시각은 한 번
|
||||
self.assertEqual(rem.run_daily_alerts(st, today=date(2026, 11, 11), slot="14:00"), 2) # 다음 시각은 또
|
||||
first = st.made[0]
|
||||
self.assertEqual((first["recipient_email"], first["kind"], first["ntype"]), ("a@x.kr", "daily@09:00", "daily"))
|
||||
self.assertEqual(first["title"], "매일 업무: 청소")
|
||||
self.assertEqual({m["recipient_email"] for m in st.made if m["task_id"] == 2}, {"b@x.kr"})
|
||||
|
||||
def test_daily_is_popup_alert_type(self):
|
||||
api = importlib.import_module("app.modules.project.router")
|
||||
self.assertIn("daily", api._ALERT_TYPES)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1653,6 +1653,32 @@ def test_reorder_keeps_linked_card_position():
|
||||
assert ST.get_task(task_id=lk["id"])["sort_order"] == lk["sort_order"]
|
||||
|
||||
|
||||
def test_repeat_daily_task_and_alerts():
|
||||
"""매일 하는 업무(2026-11-11, 마이그레이션 033) — [매일]이면 마감일을 비우고, 마감일을 고르면 꺼짐.
|
||||
알림 데몬은 미완료 매일 업무의 담당자에게 시각마다 한 번(type=daily, 큰 팝업)."""
|
||||
from datetime import date as _d
|
||||
from app.modules.project import reminders
|
||||
a = _project("P-daily", ADMIN, (ALICE,))
|
||||
sa = _stage(a["id"], by=ADMIN)
|
||||
t = ST.create_task(project_id=a["id"], title="매일 청소", stage_id=sa["id"], assignee_email=ALICE,
|
||||
due_date="2026-12-01", created_by=ALICE)
|
||||
r = req("PUT", f"/project/api/tasks/{t['id']}", ALICE, json={"due_date": None, "repeat_daily": True})
|
||||
assert r.status_code == 200, r.text
|
||||
got = r.json()["task"]
|
||||
assert got["repeat_daily"] is True and got["due_date"] is None, got
|
||||
assert req("PUT", f"/project/api/tasks/{t['id']}", ALICE, json={"repeat_daily": "yes"}).status_code == 400
|
||||
assert t["id"] in [x["id"] for x in ST.list_open_daily_tasks()]
|
||||
today = _d(2026, 11, 11)
|
||||
assert reminders.run_daily_alerts(ST, today=today, slot="09:00") >= 1
|
||||
assert reminders.run_daily_alerts(ST, today=today, slot="09:00") == 0 # 같은 시각은 한 번
|
||||
alerts = req("GET", "/project/api/notifications/alerts?after=0", ALICE).json()["alerts"]
|
||||
assert any(n["type"] == "daily" and n["task_id"] == t["id"] for n in alerts), alerts
|
||||
# 마감일을 고르면 매일 반복은 꺼진다(repeat_daily 를 안 보내도)
|
||||
got = req("PUT", f"/project/api/tasks/{t['id']}", ALICE, json={"due_date": "2026-12-05"}).json()["task"]
|
||||
assert got["repeat_daily"] is False and got["due_date"] == "2026-12-05", got
|
||||
assert t["id"] not in [x["id"] for x in ST.list_open_daily_tasks()]
|
||||
|
||||
|
||||
def test_move_stage_to_other_project():
|
||||
"""섹션째 다른 프로젝트로(2026-10-26) — 섹션 + 업무 + 세부 업무(모든 단계), 섹션은 맨 끝, 연결 정리, 권한."""
|
||||
a = _project("P-smA", ADMIN, (ALICE, BOB))
|
||||
|
||||
@@ -59,6 +59,18 @@ class NormalizeTests(unittest.TestCase):
|
||||
self.assertEqual(store.validate_project_options({"all_view_users": ["Me@X.kr"]}), {"all_view_users": ["me@x.kr"]})
|
||||
self.assertEqual(store.validate_project_options({"all_view_users": None}), {"all_view_users": None})
|
||||
|
||||
def test_daily_alert_times(self):
|
||||
self.assertEqual(D["daily_alert_times"], ["09:00"])
|
||||
out = store.normalize_project_options({"daily_alert_times": ["14:00", "9:00", "09:00"]})
|
||||
self.assertEqual(out["daily_alert_times"], ["09:00", "14:00"])
|
||||
self.assertEqual(store.normalize_project_options({"daily_alert_times": []})["daily_alert_times"], []) # 빈 목록 = 끔
|
||||
self.assertEqual(store.normalize_project_options({"daily_alert_times": ["25:00"]})["daily_alert_times"], ["09:00"])
|
||||
self.assertEqual(store.validate_project_options({"daily_alert_times": ["18:30", "08:05"]}),
|
||||
{"daily_alert_times": ["08:05", "18:30"]})
|
||||
for bad in ("09:00", ["9시"], [""], [None], ["24:00"], ["09:00"] * 0 + [f"{h:02d}:00" for h in range(13)]):
|
||||
with self.subTest(bad=bad), self.assertRaises(ValueError):
|
||||
store.validate_project_options({"daily_alert_times": bad})
|
||||
|
||||
def test_can_all_view(self):
|
||||
access = importlib.import_module("app.modules.project.access")
|
||||
self.assertTrue(access.can_all_view(PRO, None)) # 설정 전 = Pro user 이상(예전 그대로)
|
||||
|
||||
Reference in New Issue
Block a user