From a4e8e43e1a4292cb70c662fae1ed531f6be381b9 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Fri, 25 Sep 2026 09:46:57 +0900 Subject: [PATCH] =?UTF-8?q?feat(B02):=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20=EB=A7=8C=EB=93=A4=20=EB=95=8C=20=EC=8B=9C=EC=8A=A4?= =?UTF-8?q?=ED=85=9C=20=EC=96=91=EC=8B=9D=20=EC=A0=84=EB=B6=80=EB=A5=BC=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=EB=B3=B8=20=C2=B7=20=5Finitial=20=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=B5=EC=82=AC=20(PLAN=2010-5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015LuapLYqN1GGFD8Y1PStD5 --- B02_ProjRegister/B02_ProjRegister_Repository.py | 10 ++++++++++ resources/tester/test_m02_template_layers.py | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/B02_ProjRegister/B02_ProjRegister_Repository.py b/B02_ProjRegister/B02_ProjRegister_Repository.py index 4714daa9..7eedccca 100644 --- a/B02_ProjRegister/B02_ProjRegister_Repository.py +++ b/B02_ProjRegister/B02_ProjRegister_Repository.py @@ -2,6 +2,7 @@ from __future__ import annotations +import logging from datetime import datetime from pathlib import Path from typing import Any @@ -16,6 +17,9 @@ from common_util.common_util_workflow import load_project_workflow from common_util.common_util_workflow_state import initialize_project_stages from config.config_db import get_db_pool from config.config_system import STORAGE_BASE_DIR +from M02_MasterTemplete.M02_Template_Layers import seed_project + +logger = logging.getLogger(__name__) def _build_project_storage(company_id: int, user_id: int, project_id: str) -> tuple[str, Path]: @@ -40,6 +44,12 @@ def _initialize_project_storage(project_root: Path, project_id: str) -> None: "stages": [f"{stage}/{subdir}" for stage, subdir in PROJECT_STORAGE_LAYOUT_V2], }, ) + # 마스터 템플릿 — 시스템 양식 전부를 작업본 + `_initial/` 로(회사 공식이 있어도 시스템). + # 복사가 실패해도 프로젝트는 만듦 — 읽는 쪽이 시스템 양식으로 떨어짐. + try: + seed_project(project_root) + except OSError: + logger.exception("프로젝트 양식 복사 실패: project_id=%s", project_id) async def create_project( diff --git a/resources/tester/test_m02_template_layers.py b/resources/tester/test_m02_template_layers.py index 1951b72b..c8a5f125 100644 --- a/resources/tester/test_m02_template_layers.py +++ b/resources/tester/test_m02_template_layers.py @@ -208,3 +208,15 @@ def test_채운_표는_작업본을_채워_돌려주고_저장_안_함( assert row["값"]["sta"] == "NO.2" and row["값"]["pp_len|파형강관|1000"] == 12 assert got["결과"] == {"계산": {}} and got["판"] == before assert layers.version_of(root / "templates/table/구조물집계표.json") == before + + +def test_프로젝트_만들기_자리에서_시스템_양식을_복사(world: dict[str, Any], tmp_path: Path) -> None: + from B02_ProjRegister.B02_ProjRegister_Repository import _initialize_project_storage + + layers.write_template(layers.company_dir(7), "table", "구조물집계표", {"회사": 1}) + root = tmp_path / "new_project" + _initialize_project_storage(root, "new") + got = layers.read_template(root / "templates", "table", "구조물집계표") + assert got["문서"] == {"판": 1, "열": []} # 회사 공식이 있어도 시스템 + assert (root / "templates/_initial/drawing/A1_도각.json").is_file() + assert (root / "project_manifest.json").is_file()