Files
dbx-main/tests/js/render_project.py
T
king 5d054e59b6 feat(project): 4-tier roles (super/admin/pro/user), meeting header 구분
- app.store: role "pro" (ROLES, ROLE_LABELS); admin page grade select
  Admin / Pro user / User, super admin fixed to one account.
- project.access: role_of, is_pro, is_project_admin.
- router: _require_admin -> _require_pro (goals, meetings complete/delete,
  members, reorder, trash restore, assignable users); new project and
  project edit/owner change need Pro user+; task delete open to any member;
  project/section delete = Admin+ or creator; comment edit/delete of others
  and workload summary = Pro user+. Templates get pj_pro / pj_admin.
- Weekly meeting table first header "구역" -> "구분".
- Docs (CLAUDE.md, PROJECT_MODULE 6-14, overview, help page) and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 01:10:25 +09:00

77 lines
3.9 KiB
Python

"""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 %}<body>{% block topbar_after_logout %}{% endblock %}{% block topbar_actions %}{% endblock %}"
"<main class='erp-page'>{% block content %}{% endblock %}</main></body>")
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,
"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 in (("project_render.html", False), ("project_admin_render.html", True)):
render_one(env, name, admin)
def render_one(env, name: str, admin: bool) -> None:
html = env.get_template("project/project.html").render(
user={"email": ME, "is_super_admin": False}, is_admin=admin, pj_pro=admin, pj_admin=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()