Files
dbx-main/tests/js/render_project.py
T
king 20232baf06 feat(project): add font options and selected goal text formatting
Restore the board header add button to the task side panel while keeping footer quick entry. Add safe, persisted goal text formatting and self-hosted Project font preferences with shared help updates and regression coverage.
2026-10-02 17:28:54 +09:00

72 lines
3.8 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"] = {}
html = env.get_template("project/project.html").render(
user={"email": ME, "is_super_admin": False}, is_admin=False, 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, "project_render.html")
io.open(path, "w", encoding="utf-8", newline="\n").write(html)
print("rendered:", path)
if __name__ == "__main__":
main()