34b8e2fb6b
- 옵션 창 "프로젝트 화면" 분류에 처음 여는 탭과 묶어 대상자 선택(아이콘+이름 체크, 전체 선택/해제) - 옵션 키 all_view_users(이메일 목록, DB 변경 없음) — 설정 전(null)은 예전처럼 Pro user 이상 - 사이드바 pj_all_view(access.can_all_view), project.js canAllView 로 메뉴 표시만 판단 - assignable-users 에 pro 표시(기본 체크용), 도움말·모듈 CLAUDE.md 갱신, 정적 파일 ?v= 올림 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
222 lines
13 KiB
Python
222 lines
13 KiB
Python
"""연간 목표(goals.html)·주간 회의록(goal_meeting.html)을 테스트용 HTML 로 렌더한다(erp_base.html 은 최소 스텁, 가상의 데이터).
|
|
|
|
python tests/js/render_goals.py # → tests/js/.out/goals_admin.html · goals_ro.html · meeting_admin.html · meeting_err.html · meeting_ro.html
|
|
|
|
칸 배치는 실제 라우터 도우미(_goal_area_layout·_goal_label_spans)로 만든다. DB·실적 모듈은 쓰지 않는다.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import copy
|
|
import io
|
|
import os
|
|
import sys
|
|
|
|
import jinja2
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
sys.path.insert(0, ROOT)
|
|
OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
|
|
|
|
from app.modules.project import store # noqa: E402
|
|
from app.modules.project.router import _goal_area_layout, _goal_label_spans, _meeting_label_spans # noqa: E402
|
|
|
|
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"
|
|
|
|
|
|
def board() -> dict:
|
|
rows_a = [{"id": 10, "label": "신제품", "cells": {0: "연간 계획", 1: "original"}, "merges": {}},
|
|
{"id": 11, "label": "리뉴얼", "cells": {}, "merges": {}}]
|
|
rows_b = [{"id": 20, "label": "쿠팡", "cells": {2: "행사"}, "merges": {}},
|
|
{"id": 21, "label": "", "cells": {}, "merges": {}}]
|
|
areas = [{"id": 1, "name": "상품", "color": "#fde2e4", "rows": rows_a},
|
|
{"id": 2, "name": "유통", "color": "", "rows": rows_b}]
|
|
for a in areas:
|
|
_goal_area_layout(a["rows"], 10)
|
|
_goal_label_spans(a["rows"])
|
|
return {
|
|
"year": 2026, "sales_unit": "만원", "halves": True, "quarters": True,
|
|
"metrics": {"sales": {"target_label": {1: "100", 2: "100"}, "actual_label": {1: "50"}},
|
|
"roas": {"target_label": {}, "actual_label": {}}},
|
|
"areas": areas,
|
|
}
|
|
|
|
|
|
def goals_ctx(admin: bool) -> dict:
|
|
return {
|
|
"user": {"email": ME, "is_super_admin": False}, "is_admin": admin, "pj_pro": admin, "pj_admin": admin, "pj_all_view": admin, "nav_projects": [], "goal_years": [2026],
|
|
"goal_year_active": 2026, "my_open_total": 0, "mention_unread": 0, "color_palette": ["#4573d2"],
|
|
"project_icons": ["folder"], "goals_enabled": True, "goal_year": 2026, "board": board(),
|
|
"months": list(range(1, 13)),
|
|
"quarters": [(q, list(range(q * 3 - 2, q * 3 + 1)), store.GOAL_QUARTER_COL[q], f"{q}분기") for q in (1, 2, 3, 4)],
|
|
"this_month": 10, "goal_area_colors": list(store.GOAL_AREA_COLORS),
|
|
}
|
|
|
|
|
|
def week_targets() -> dict:
|
|
"""2026년 달마다 주차(store.month_weeks) — 1월 1·2주차만 값(100·200)."""
|
|
out = {}
|
|
for mo in range(1, 13):
|
|
out[mo] = [{"start": a.isoformat(), "n": i + 1, "days": (b - a).days + 1, "label": f"{a.month}/{a.day}~{b.month}/{b.day}",
|
|
"value": {(1, 0): "100", (1, 1): "200"}.get((mo, i), ""),
|
|
# 두 칸(030) — 1주차 = 유통·인플 60 + 카페24·네이버 40, 2주차 = 예전 한 칸 값(유통·인플 칸에 미리)
|
|
"dist": {(1, 0): "60", (1, 1): "200"}.get((mo, i), ""), "mall": {(1, 0): "40"}.get((mo, i), "")}
|
|
for i, (a, b) in enumerate(store.month_weeks(2026, mo))]
|
|
return out
|
|
|
|
|
|
def meeting_view(err: bool) -> dict:
|
|
"""회의록 2026-09-28 주 — 유통 쿠팡(쇼핑몰 연결 — 화면엔 자동 실적 없음, 정량 목표 100), 상품1(직접 입력 결과)."""
|
|
prev_cou = {"id": 901, "week_start": "2026-09-21", "content": "지난주 행사", "target_amount": 100, "result_amount": None,
|
|
"status": "", "marketplace_code": "coupang", "period": "9/21~9/27", "not_started": False,
|
|
"market_off": False, "auto_error": err, "auto_result": None if err else 80,
|
|
"result": None if err else 80, "market_name": "쿠팡"}
|
|
prev_p1 = {"id": 902, "week_start": "2026-09-21", "content": "샘플", "result_note": "샘플 결과", "target_amount": 200, "result_amount": 100,
|
|
"status": "partial", "marketplace_code": "", "period": "9/21~9/27", "not_started": False,
|
|
"market_off": False, "auto_error": False, "auto_result": None, "result": 100, "market_name": ""}
|
|
it_cou = {"id": 1, "section": "유통", "section_color": "", "label": "쿠팡", "content": "original",
|
|
"target_amount": 100, "marketplace_code": "coupang", "market_name": "쿠팡", "market_off": False,
|
|
"market_unknown": err, "week_auto": None if err else 100, "week_error": err,
|
|
"prev": prev_cou, "rate": None if err else 80.0}
|
|
it_p1 = {"id": 2, "section": "상품", "section_color": "#fde2e4", "label": "상품1", "content": "",
|
|
"target_amount": None, "marketplace_code": "", "market_name": "", "market_off": False,
|
|
"market_unknown": False, "week_auto": None, "week_error": False, "prev": prev_p1, "rate": 50.0}
|
|
it_new = {"id": 3, "section": "상품", "section_color": "#fde2e4", "label": "새 줄", "content": "",
|
|
"target_amount": None, "marketplace_code": "", "market_name": "", "market_off": False,
|
|
"market_unknown": False, "week_auto": None, "week_error": False, "prev": None, "rate": None}
|
|
meeting = {"week_start": "2026-09-28", "week_target": 1000, "attendees": "", "notes": "메모 원본", "cell_merges": True, "result_notes": True,
|
|
"items": [it_p1, it_new, it_cou],
|
|
"sections": [{"name": "상품", "color": "#fde2e4", "rows": [it_p1, it_new]},
|
|
{"name": "유통", "color": "", "rows": [it_cou]}]}
|
|
head = {"sales_unit": "원", "sales_target": 10000.0, "roas_target": None, "month_target_won": 10000,
|
|
"mtd": None if err else 0, "mtd_end": "2026-09-27", "weeks_left": 1,
|
|
"need_per_week": None if err else 10000, "prev_target": 500, "prev_exists": True,
|
|
"prev_result": None if err else 0, "week_result": None if err else 0,
|
|
"week_targets_set": True, "cum_target": 4000.0, "cum_target_won": 4000,
|
|
"gap": None if err else -4000, "rate": None if err else 0.0,
|
|
"perf": True, "perf_state": "error" if err else "ok",
|
|
"unknown": ["mtd", "prev_result", "week_result"] if err else [],
|
|
"fresh_oldest": "" if err else "10/01 14:20",
|
|
"fresh_tip": "" if err else "매출 자료(실적 모듈) 쇼핑몰별 마지막 갱신 성공 — 쿠팡 10/01 14:20"}
|
|
return {"meeting": meeting, "head": head, "markets": [] if err else [{"code": "coupang", "name": "쿠팡"}]}
|
|
|
|
|
|
def meeting_ctx(admin: bool, err: bool, can_sync: bool = True) -> dict:
|
|
view = meeting_view(err)
|
|
ctx = {
|
|
"user": {"email": ME, "is_super_admin": False}, "is_admin": admin, "pj_pro": admin, "pj_admin": admin, "pj_all_view": admin, "nav_projects": [], "goal_years": [2026],
|
|
"goal_year_active": 2026, "my_open_total": 0, "mention_unread": 0, "color_palette": ["#4573d2"],
|
|
"project_icons": ["folder"], "goal_year": 2026, "goal_month": 9, "meetings_enabled": True,
|
|
"weeks": [{"start": "2026-09-28", "end": "2026-10-04", "n": 4, "label": "9/28~10/4", "has": True, "now": False,
|
|
"days": []}],
|
|
"cal_weeks": [], "week": "2026-09-28", "week_n": 4, "week_end": "2026-10-04",
|
|
"prev_week": "2026-09-21", "prev_week_end": "2026-09-27", "sync_from": "2026-09-21", "sync_to": "2026-10-01",
|
|
"can_sync": can_sync, "meeting_status": store.MEETING_STATUS, "meet_members": [], "month_plan": None,
|
|
"attendee_list": [], **copy.deepcopy(view),
|
|
}
|
|
# 회의록은 누구나 고친다(2026-10-07) — 보기 전용은 "회의 완료"된 회의록뿐. 관리자 아닌 화면 = 완료된 회의록으로 시험
|
|
ctx["meeting"].update(can_complete=True, completed=not admin, completed_at="2026-10-02 18:00" if not admin else "",
|
|
completed_by="admin@test.local" if not admin else "")
|
|
return ctx
|
|
|
|
|
|
def member_ctx() -> dict:
|
|
ctx = meeting_ctx(False, False, can_sync=False)
|
|
ctx["meeting"].update(completed=False, completed_at="", completed_by="")
|
|
return ctx
|
|
|
|
|
|
def meeting_layout_ctx(admin: bool) -> dict:
|
|
ctx = meeting_ctx(admin, False, can_sync=False)
|
|
meeting = ctx["meeting"]
|
|
product = meeting["sections"][0]["rows"][0]
|
|
product["content"] = "첫 번째 줄\n두 번째 줄\n세 번째 줄"
|
|
product["prev"]["content"] = "첫 번째 줄\n두 번째 줄"
|
|
inactive = copy.deepcopy(meeting["sections"][1]["rows"][0])
|
|
inactive.update(id=4, label="네이버", section="마케팅", content="한 줄", marketplace_code="naver",
|
|
market_name="네이버 스마트스토어", market_off=True, week_auto=None)
|
|
inactive["prev"].update(id=904, content="한 줄", auto_result=None, market_off=True,
|
|
marketplace_code="naver", market_name="네이버 스마트스토어")
|
|
meeting["items"].append(inactive)
|
|
meeting["sections"].append({"name": "마케팅", "color": "", "rows": [inactive]})
|
|
return ctx
|
|
|
|
|
|
def meeting_merged_ctx() -> dict:
|
|
ctx = meeting_ctx(True, False, can_sync=False)
|
|
a, b = ctx["meeting"]["sections"][0]["rows"]
|
|
a.update(content_span=2, content_hidden=False,
|
|
content_html=store.goal_text_html(store.GOAL_RICH_PREFIX + '[{"text":"병합한 계획\\n두 번째 줄","bold":true,"size":24}]'))
|
|
b["content_hidden"] = True
|
|
return ctx
|
|
|
|
|
|
def meeting_groups_ctx(added: bool = False) -> dict:
|
|
"""항목 칸 묶음(027) — 상품 구역: 상품1(묶음 첫 줄) + 이어 붙은 줄(id 3, label_cont) — 실제 라우터 도우미로 칸 계산.
|
|
added = 상품1 아래에 같은 항목 칸으로 줄(id 9)을 추가한 뒤의 화면(다시 받기 응답)."""
|
|
ctx = meeting_ctx(True, False, can_sync=False)
|
|
rows = ctx["meeting"]["sections"][0]["rows"]
|
|
rows[1].update(label="", label_cont=True)
|
|
if added:
|
|
new = copy.deepcopy(rows[1])
|
|
new.update(id=9, content="", target_amount=None, prev=None)
|
|
rows.insert(1, new)
|
|
ctx["meeting"]["items"].insert(1, new)
|
|
for sec in ctx["meeting"]["sections"]:
|
|
_meeting_label_spans(sec["rows"])
|
|
return ctx
|
|
|
|
|
|
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"] = {}
|
|
os.makedirs(OUT_DIR, exist_ok=True)
|
|
pages = {
|
|
"goals_admin.html": ("project/goals.html", goals_ctx(True)),
|
|
"goals_ro.html": ("project/goals.html", goals_ctx(False)),
|
|
# 주차별 매출 목표(020) — 매출 목표 칸이 주차 입력 창을 연다
|
|
"goals_weekly_admin.html": ("project/goals.html", goals_ctx(True) | {"week_targets": week_targets()}),
|
|
"goals_weekly_split.html": ("project/goals.html", goals_ctx(True) | {"week_targets": week_targets(), "week_split": True}),
|
|
"meeting_admin.html": ("project/goal_meeting.html", meeting_ctx(True, False)),
|
|
"meeting_err.html": ("project/goal_meeting.html", meeting_ctx(True, True)),
|
|
"meeting_ro.html": ("project/goal_meeting.html", meeting_ctx(False, False, can_sync=False)),
|
|
# 관리자 아닌 직원 + 아직 완료 전 회의록 — 누구나 고친다(2026-10-07)
|
|
"meeting_member.html": ("project/goal_meeting.html", member_ctx()),
|
|
"meeting_layout_admin.html": ("project/goal_meeting.html", meeting_layout_ctx(True)),
|
|
"meeting_layout_ro.html": ("project/goal_meeting.html", meeting_layout_ctx(False)),
|
|
"meeting_merged.html": ("project/goal_meeting.html", meeting_merged_ctx()),
|
|
"meeting_groups.html": ("project/goal_meeting.html", meeting_groups_ctx()),
|
|
"meeting_groups_added.html": ("project/goal_meeting.html", meeting_groups_ctx(added=True)),
|
|
"meeting_content_admin.html": ("project/goal_meeting.html", meeting_ctx(True, False, can_sync=False) | {"meeting_embedded": True}),
|
|
"meeting_content_ro.html": ("project/goal_meeting.html", meeting_ctx(False, False, can_sync=False) | {"meeting_embedded": True}),
|
|
}
|
|
for name, (tpl, ctx) in pages.items():
|
|
html = env.get_template(tpl).render(**ctx)
|
|
path = os.path.join(OUT_DIR, name)
|
|
io.open(path, "w", encoding="utf-8", newline="\n").write(html)
|
|
print("rendered:", path)
|
|
|
|
# 왼쪽을 유지하는 브라우저 검증은 실제 ERP 기본 레이아웃도 사용한다.
|
|
shell_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
|
|
jinja2.FileSystemLoader(os.path.join(ROOT, "app", "modules", "project", "templates")),
|
|
jinja2.FileSystemLoader(os.path.join(ROOT, "app", "templates")),
|
|
]), autoescape=True)
|
|
shell_env.globals["pj_kr_holidays"] = {}
|
|
for name, ctx in [("meeting_shell_admin.html", meeting_ctx(True, False, can_sync=False)),
|
|
("goals_shell_admin.html", goals_ctx(True))]:
|
|
ctx.update(nav_items=[], force_sidebar_collapsed=True, page_title="목표·회의록 검증", goal_years=[2027, 2026])
|
|
ctx["user"]["name"] = "Tester"
|
|
html = shell_env.get_template("project/goals.html" if name.startswith("goals") else "project/goal_meeting.html").render(**ctx)
|
|
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()
|