48cd7f0878
- 이름 목록: × 한 명씩 빼기·[전체 삭제], 이름 넣기는 목록에 더함
- 본문: 바로 고침(plaintext-only), {이름} 자리 = 분홍 칩, 이름 누르면 고친 글 + 이름 복사
- 저장한 본문(본문 오른쪽): 설정 DM 문구 + 저장한 것, 고르기·[저장]·[새 본문으로 저장]·× 지우기
- outreach_db 마이그레이션 002 outreach_dm_bodies + POST/PUT/DELETE /outreach/api/dm-bodies
(002 미적용이면 목록 안내만, API 503)
- 캐시 버전 20261030c, 단위·API·실제 PG·브라우저 테스트
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.7 KiB
Python
61 lines
3.7 KiB
Python
"""안내문 발송 화면(index.html)을 진짜 ERP 셸로 렌더 — 브라우저 테스트용(2026-10-27).
|
|
|
|
python tests/js/render_outreach.py # → tests/js/.out/outreach.html, outreach_dm.html, outreach_settings.html
|
|
|
|
화면 데이터는 실제 router._view 로 만든다(저장소 없이 줄만 가짜).
|
|
"""
|
|
|
|
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.outreach import store # noqa: E402
|
|
from app.modules.outreach.router import _view # 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", "outreach", "templates")]), autoescape=True)
|
|
t = {**store.normalize_template(None), "updated_by": "", "updated_at": "", "is_default": True}
|
|
base = {"id": 0, "memo": "", "status": "대기", "sent_at": "", "sent_by": "", "sent_via": "", "last_error": ""}
|
|
raw = [
|
|
{**base, "id": 1, "kind": "email", "handle": "kim@miras.co.kr", "address": "kim@miras.co.kr", "name": "김철수"},
|
|
{**base, "id": 2, "kind": "instagram", "handle": "mira.kitchen", "address": "@mira.kitchen", "name": "미라"},
|
|
{**base, "id": 3, "kind": "email", "handle": "noname@miras.co.kr", "address": "noname@miras.co.kr", "name": ""},
|
|
{**base, "id": 4, "kind": "email", "handle": "done@miras.co.kr", "address": "done@miras.co.kr", "name": "보냄씨",
|
|
"status": "보냄", "sent_at": "2026-10-27T10:00:00+09:00", "sent_via": "gmail"},
|
|
]
|
|
ctx = {"user": {"email": "me@miras.co.kr", "name": "나", "picture": ""}, "is_admin": False, "nav_items": [],
|
|
"page_title": "안내문 발송", "page_subtitle": "", "template": t, "body_text": store.html_to_text(t["body"]),
|
|
"needs_name": store.needs_name(t), "images": [], "rows": [_view(r, t) for r in raw],
|
|
"active_tab": "list",
|
|
"logs": [], "gmail": {"available": True, "connected": True, "email": "me@miras.co.kr"}, "msg": ""}
|
|
with open(os.path.join(OUT_DIR, "outreach.html"), "w", encoding="utf-8") as f:
|
|
f.write(env.get_template("outreach/index.html").render(**ctx))
|
|
# DM 수동 보내기 탭(2026-10-30)
|
|
with open(os.path.join(OUT_DIR, "outreach_dm.html"), "w", encoding="utf-8") as f:
|
|
f.write(env.get_template("outreach/dm.html").render(**{**ctx, "active_tab": "dm", "dm_template": store.dm_text(t, store.NAME_TAG),
|
|
"dm_bodies": [], "dm_max": store.DM_MAX}))
|
|
# 설정 화면 — 저장해 둔 서식 본문(HTML)·DM 문구로
|
|
saved = store.normalize_template({
|
|
"subject": "{이름}님께 제안", "fmt": "html", "dm_body": "안녕하세요 {이름}님, DM 입니다",
|
|
"body": '<p>안녕하세요, {이름}님.</p><p><br></p><p><span style="font-size: 20px; color: rgb(0, 102, 204)">큰 파란 글씨</span></p>'
|
|
'<ul><li>하나</li><li>둘</li></ul><p style="text-align: center"><strong>가운데 굵게</strong></p>'})
|
|
sctx = {**ctx, "page_title": "설정", "template": {**saved, "updated_by": "me@miras.co.kr", "updated_at": "2026-10-27T10:00:00",
|
|
"is_default": False},
|
|
"default": store.normalize_template(None), "max_images": 10, "dm_max": store.DM_MAX}
|
|
with open(os.path.join(OUT_DIR, "outreach_settings.html"), "w", encoding="utf-8") as f:
|
|
f.write(env.get_template("outreach/settings.html").render(**sctx))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|