"""휴가 신청 화면(form.html)을 진짜 ERP 셸(erp_base.html)로 렌더 — 날짜 팝업 브라우저 테스트용(2026-10-27). python tests/js/render_vacation.py # → tests/js/.out/vac_form.html DB 없이 화면 데이터만 만든다(공휴일 = 휴가 설정 공휴일 모양 {날짜: 이름}). """ from __future__ import annotations 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.vacation.store import HALF_LABELS, HALVES, VACATION_TYPES # noqa: E402 def main() -> None: os.makedirs(OUT_DIR, exist_ok=True) env = jinja2.Environment(loader=jinja2.FileSystemLoader([ os.path.join(ROOT, "app", "templates"), os.path.join(ROOT, "app", "modules", "vacation", "templates")]), autoescape=True) ctx = {"user": {"email": "kim@test.local", "name": "김철수", "picture": ""}, "is_admin": False, "is_approver": False, "nav_items": [], "page_title": "휴가 신청", "page_subtitle": "", "mode": "new", "req": None, "default_date": "2026-10-27", "vacation_types": list(VACATION_TYPES), "halves": list(HALVES), "half_labels": HALF_LABELS, "holidays": {"2026-10-01": "부처님오신날", "2026-10-03": "개천절", "2026-10-09": "한글날", "2026-12-25": "성탄절"}, # 10-01 = 가장 긴 이름(석가탄신일) 칸 맞춤 확인용 "consult_ready": True, "consult_chosen": {}, "members": [{"email": "lee@test.local", "name": "이팀장", "picture": ""}, {"email": "park@test.local", "name": "박과장", "picture": ""}, {"email": "choi@test.local", "name": "최대리", "picture": ""}], "line": {"approvers": [{"email": "rj@test.local", "name": "RJ", "picture": ""}], "notifiers": [{"email": "ellen@test.local", "name": "Ellen", "picture": ""}]}} html = env.get_template("vacation/form.html").render(**ctx) with open(os.path.join(OUT_DIR, "vac_form.html"), "w", encoding="utf-8") as f: f.write(html) # 옵션 — 잔여 연차 표(2026-10-27 입사일 기준, 오늘 = 2026-10-26 고정) → tests/js/.out/vac_options.html row = {"active": True, "picture": "", "service_years": 0, "period_start": "", "period_end": "", "granted": 0.0, "granted_so_far": 0.0, "upcoming": 0.0, "grants_tip": "", "total": None, "prior": 0.0, "used": 0.0, "available": None, "expiring": None, "memo": "", "hire_date": ""} octx = {**ctx, "page_title": "휴가 — 옵션", "is_admin": True, "can_edit": True, "msg": "", "options": {"approvers": [], "notifiers": [], "ready": True, "updated_by": "", "updated_at": ""}, "candidates": [], "effective_approvers": [], "gmail": {"available": False, "connected": False, "smtp": True}, "bal_today": "2026-10-26", "bal_prior_col": True, "system_start_year": 2026, "hire_ready": True, "bal_rows": [ {**row, "email": "lee@test.local", "name": "이팀장", "hire_date": "2020-03-02", "service_years": 6, "period_start": "2026-03-02", "period_end": "2027-03-01", "granted": 17.0, "granted_so_far": 17.0, "grants_tip": "26-03-02 근속 6년 17일(~27-03-01)", "used": 4.5, "available": 12.5, "expiring": {"date": "2027-03-01", "days": 12.5}}, {**row, "email": "kim@test.local", "name": "김철수"}, ]} html = env.get_template("vacation/options.html").render(**octx) with open(os.path.join(OUT_DIR, "vac_options.html"), "w", encoding="utf-8") as f: f.write(html) if __name__ == "__main__": main()