"""project/project.html 을 테스트용 HTML 로 렌더한다(erp_base.html 은 최소 스텁, 가상의 데이터). python tests/js/render_project.py # → tests/js/.out/project_render.html """ from __future__ import annotations import io import os import jinja2 ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) OUT_DIR = os.path.join(ROOT, "tests", "js", ".out") BASE_STUB = ("{% block head_extra %}{% endblock %}{% block topbar_after_logout %}{% endblock %}{% block topbar_actions %}{% endblock %}" "
{% block content %}{% endblock %}
") ME = "me@test.local" STAGES = { 1: [{"id": 11, "project_id": 1, "name": "할 일", "is_done_stage": False, "sort_order": 0, "color": None, "created_by": ME, "default_assignee_email": ""}, {"id": 12, "project_id": 1, "name": "완료", "is_done_stage": True, "sort_order": 1, "color": None, "created_by": ME, "default_assignee_email": ""}], 2: [{"id": 21, "project_id": 2, "name": "할 일", "is_done_stage": False, "sort_order": 0, "color": None, "created_by": ME, "default_assignee_email": ""}], } def task(tid: int, title: str, pid: int, stage: int, *, ctx: int | None = None, linked: bool = False) -> dict: return {"id": tid, "title": title, "project_id": pid, "context_project_id": ctx or pid, "is_linked": linked, "stage_id": stage, "home_stage_id": stage, "stage_name": "할 일", "is_done_stage": False, "description": "", "assignee_email": "", "assignee_name": "", "priority": "normal", "start_date": None, "due_date": None, "completed_at": None, "created_by": ME, "created_at": "2026-10-21T13:05:09+09:00", "parent_task_id": None, "comment_count": 0, "subtask_count": 0, "subtask_done": 0, "project_name": {1: "P1", 2: "P2", 3: "비밀"}[pid], "project_color": "#4573d2", "sort_order": tid} TASKS = [task(101, "작업 A", 1, 11), task(102, "작업 B", 1, 11), task(103, "작업 C", 2, 21), task(301, "연결된 작업", 3, 99, ctx=1, linked=True)] PROJECTS = [{"id": 1, "name": "P1", "color": "#4573d2", "icon": "", "start_date": None, "due_date": None, "created_by": ME, "description": "", "status": "active"}, {"id": 2, "name": "P2", "color": "#f06a6a", "icon": "", "start_date": None, "due_date": None, "created_by": ME, "description": "", "status": "active"}] def main() -> None: env = jinja2.Environment(loader=jinja2.ChoiceLoader([ jinja2.DictLoader({"erp_base.html": BASE_STUB}), jinja2.FileSystemLoader(os.path.join(ROOT, "app", "modules", "project", "templates")), ])) env.globals["pj_kr_holidays"] = {} for name, admin, sup in (("project_render.html", False, False), ("project_admin_render.html", True, False), ("project_super_render.html", True, True)): render_one(env, name, admin, sup) render_inbox(env) render_mytasks(env) def render_mytasks(env) -> None: """내 업무(project/mytasks.html) — 내 업무 101·102, 남의 상위 업무 아래 내 세부 업무 501.""" def t(tid: int, title: str, **kw) -> dict: base = {"id": tid, "title": title, "project_id": 1, "project_name": "P1", "project_color": "#4573d2", "stage_name": "할 일", "assignee_email": ME, "priority": "normal", "due_date": None, "start_date": None, "completed_at": None, "comment_count": 0, "subtask_total": 0, "subtask_done": 0, "parent_task_id": None} base.update(kw) return base html = env.get_template("project/mytasks.html").render( user={"email": ME, "is_super_admin": False}, is_admin=False, pj_pro=False, pj_admin=False, nav_projects=PROJECTS, goal_years=[2026], my_open_total=3, mention_unread=0, color_palette=["#4573d2"], project_icons=["folder"], project_asana_icons=[], my_tasks=[t(101, "작업 A"), t(102, "작업 B"), t(501, "내 세부", parent_task_id=300, parent_title="남의 상위", parent_assignee_email="bob@test.local")], avatars={}, priority_labels={"low": "낮음", "normal": "보통", "high": "높음"}, today="2026-10-13", ) path = os.path.join(OUT_DIR, "mytasks_render.html") io.open(path, "w", encoding="utf-8", newline="\n").write(html) print("rendered:", path) def render_inbox(env) -> None: """수신함(project/inbox.html) — 태그한 작업 101·102, 알림(작업 101·102·프로젝트만).""" def mt(tid: int, title: str) -> dict: return {"id": tid, "title": title, "project_id": 1, "project_name": "P1", "project_color": "#4573d2", "unread_mentions": 1, "stage_name": "할 일", "due_label": "", "mention_actor": "bob@test.local", "completed_at": None} def nt(nid: int, ntype: str, title: str, task_id: int | None) -> dict: return {"id": nid, "type": ntype, "title": title, "body": "P1", "task_id": task_id, "project_id": 1, "is_read": False, "actor_email": "bob@test.local", "created_at": "2026-10-12T09:00:00+09:00"} html = env.get_template("project/inbox.html").render( user={"email": ME, "is_super_admin": False}, is_admin=False, pj_pro=False, pj_admin=False, nav_projects=PROJECTS, goal_years=[2026], my_open_total=0, mention_unread=2, color_palette=["#4573d2"], project_icons=["folder"], project_asana_icons=[], mentioned_tasks=[mt(101, "작업 A"), mt(102, "작업 B")], notifications=[nt(901, "assigned", "작업 배정: 작업 A", 101), nt(902, "comment", "새 댓글: 작업 B", 102), nt(903, "completed", "프로젝트 알림", None)], ) path = os.path.join(OUT_DIR, "inbox_render.html") io.open(path, "w", encoding="utf-8", newline="\n").write(html) print("rendered:", path) def render_one(env, name: str, admin: bool, sup: bool = False) -> None: html = env.get_template("project/project.html").render( user={"email": ME, "is_super_admin": sup}, is_admin=admin, pj_pro=admin, pj_admin=admin, pj_all_view=admin, can_manage=True, project=PROJECTS[0], current_project_id=1, stages=STAGES[1], tasks=TASKS, members=[{"user_email": ME, "role": "member"}, {"user_email": "bob@test.local", "role": "member"}], projects_meta=PROJECTS, nav_projects=PROJECTS, stages_by_project=STAGES, board_stage_names=["할 일", "완료"], avatars={}, priority_labels={"low": "낮음", "normal": "보통", "high": "높음"}, color_palette=["#4573d2"], project_icons=["folder"], stage_color_palette=["#c7c4c4"], today="2026-09-30", holidays={}, year=2026, month=9, prev_y=2026, prev_m=8, next_y=2026, next_m=10, weekdays=["일", "월", "화", "수", "목", "금", "토"], weeks=[], goal_years=[2026], my_open_total=0, mention_unread=0, ) os.makedirs(OUT_DIR, exist_ok=True) path = os.path.join(OUT_DIR, name) io.open(path, "w", encoding="utf-8", newline="\n").write(html) print("rendered:", path) if __name__ == "__main__": main()