From 39dc28d6646fdc0f43a4ed09b57db3cf36bfc118 Mon Sep 17 00:00:00 2001 From: king Date: Fri, 14 Aug 2026 15:46:32 +0900 Subject: [PATCH] =?UTF-8?q?feat(cafe24):=20=ED=8E=B8=EC=A7=91=EA=B8=B0?= =?UTF-8?q?=EC=97=90=EC=84=9C=20PC/=EB=AA=A8=EB=B0=94=EC=9D=BC=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84=20=EC=A0=9C=EA=B1=B0=20=E2=80=94=20=ED=95=AD=EC=83=81?= =?UTF-8?q?=20=EA=B0=99=EC=9D=80=20=EB=82=B4=EC=9A=A9=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 요청대로 단순화했다. 모바일 상세설명 보기 영역과 「모바일도 함께」 체크박스를 없애고, 적용 시 description 과 mobile_description 에 **항상 같은 HTML** 을 쓴다. separated_mobile_description 값과 무관하므로 한쪽만 바뀌어 어긋나는 사고가 없어진다. 다만 분리 사용 상품의 모바일 내용이 PC 와 달랐다면 그 내용을 덮어쓰게 된다. 그래서 쓰기 전에 **모바일 내용도 BACKUP revision 으로 따로 남긴다** — 백업이 없으면 되찾을 방법이 없다. 기존 BACKUP 은 PC 값만 담고 있었다. 부수 정리: 편집기 컨텍스트에서 html_mobile 제거, mobile_html 의 None 분기 제거, 감사로그 표기를 "PC·모바일 동시 반영"으로 고정, 라벨을 "상세설명 HTML · PC/모바일 공통"으로 변경. 검증: 유닛테스트 51개 통과. 분리+내용상이 상품으로 편집기를 렌더해 모바일 보기 영역· 체크박스가 사라지고 공통 문구·버전 이력·다시 읽기가 남은 것을 확인. Co-Authored-By: Claude Opus 5 --- app/modules/cafe24/routes_products.py | 38 ++++++++++--------- .../cafe24/templates/cafe24/_editor.html | 38 +------------------ app/modules/cafe24/templates/cafe24/bulk.html | 2 +- .../cafe24/templates/cafe24/products.html | 2 +- .../cafe24/templates/cafe24/schedules.html | 2 +- .../cafe24/templates/cafe24/system.html | 2 +- docs/CAFE24_MODULE.md | 25 ++++++------ 7 files changed, 38 insertions(+), 71 deletions(-) diff --git a/app/modules/cafe24/routes_products.py b/app/modules/cafe24/routes_products.py index 044a2f4..04425aa 100644 --- a/app/modules/cafe24/routes_products.py +++ b/app/modules/cafe24/routes_products.py @@ -17,6 +17,9 @@ MANUAL 버전 + 감사로그 로컬 DB 의 마지막 버전을 "지금 카페24에 올라간 값"으로 가정하지 않는다. +PC/모바일은 구분하지 않는다 — 적용 시 `description` 과 `mobile_description` 에 +같은 HTML 을 쓴다(운영 방침). 분리 사용 상품이어도 한쪽만 바뀌는 일이 없다. + 이미지 경로의 한글은 카페24에 퍼센트 인코딩으로 저장돼 있다. 편집기에는 `store.decode_html_urls` 로 풀어서 보여주고, 저장할 때 `encode_html_urls` 로 되돌린다(왕복 보존 — store.py 주석 참고). @@ -139,9 +142,6 @@ def _editor_ctx(st: Any, product_no: int) -> dict[str, Any]: # (2) 태그마다 줄을 나눠 정리해서 보여준다. # 저장할 때 같은 정리를 거친 값을 카페24에 쓴다(화면과 저장값이 같다). "html_pc": store.format_html(store.decode_html_urls(desc.description)) if desc else "", - "html_mobile": ( - store.format_html(store.decode_html_urls(desc.mobile_description)) if desc else "" - ), # 지문은 **인코딩된 원본**으로 만든다(적용 직전 카페24 값과 비교하므로). "fingerprint": store.fingerprint(desc.description) if desc else "", "revisions": st.list_revisions(product_no, limit=20), @@ -241,7 +241,6 @@ def product_apply( base_fingerprint: str = Form(""), memo: str = Form(""), list_query: str = Form(""), - apply_mobile: str = Form(""), ): """편집한 HTML 을 카페24에 즉시 적용한다. @@ -251,8 +250,8 @@ def product_apply( 3) 편집 시작 시점의 지문과 비교해 충돌이면 거부한다 4) 쓰고, MANUAL 버전과 감사로그를 남긴다 - PC/모바일 미분리 상품은 모바일 필드도 같은 HTML 로 맞춘다. 분리 상품은 - 모바일을 건드리지 않는다(화면에 별도 반영 안내를 띄운다). + PC/모바일을 구분하지 않는다 — 두 필드에 같은 HTML 을 쓴다. 분리 사용 상품의 + 모바일 내용이 PC 와 달랐다면 덮어쓰기 전에 그 내용도 BACKUP 으로 남긴다. """ checked = guard(request) if not isinstance(checked, tuple): @@ -290,6 +289,16 @@ def product_apply( memo="적용 직전 자동 백업", created_by=actor, ) + # 모바일 내용이 PC 와 달랐다면 그것도 따로 남긴다. 아래에서 모바일을 PC 와 같게 + # 덮어쓰므로, 백업하지 않으면 그 내용을 되찾을 방법이 없다. + if current.mobile_description and current.mobile_description != current.description: + st.add_revision( + product_no=product_no, + html_content=current.mobile_description, + revision_type=store.REVISION_BACKUP, + memo="적용 직전 자동 백업 (모바일 — PC와 달랐던 내용)", + created_by=actor, + ) if base_fingerprint and base_fingerprint != store.fingerprint(current.description): st.log_audit( @@ -301,17 +310,11 @@ def product_apply( status_code=303, ) - # 미분리 상품은 모바일도 함께 맞춘다 — PC 만 바꾸면 모바일 상세가 어긋난다. - # 분리 상품은 화면의 「모바일도 함께」 체크에 따른다(두 내용이 같으면 기본 체크, - # 다르면 기본 해제 — 일부러 다르게 만든 모바일 페이지를 덮어쓰지 않기 위해). - if current.separated_mobile: - mobile_html = submitted if apply_mobile else None - else: - mobile_html = submitted + # PC/모바일을 구분하지 않는다 — 항상 같은 내용으로 함께 쓴다(운영 방침). + # 분리 사용 상품이어도 모바일에 같은 HTML 을 넣으므로 한쪽만 바뀌는 일이 없다. + mobile_html = submitted - if submitted == current.description and ( - mobile_html is None or mobile_html == current.mobile_description - ): + if submitted == current.description and mobile_html == current.mobile_description: return RedirectResponse(url=f"{back}&msg=변경된 내용이 없어 적용하지 않았습니다.", status_code=303) try: products.update_descriptions( @@ -338,8 +341,7 @@ def product_apply( st.log_audit( actor=actor, action="apply_description", product_no=product_no, revision_id=revision_id, result="SUCCESS", - detail=f"{len(submitted)}자 적용 (백업 {backup_id}" - + (", 모바일 동시 반영)" if mobile_html is not None else ")"), + detail=f"{len(submitted)}자 적용 (백업 {backup_id}, PC·모바일 동시 반영)", ) logger.info("카페24 상품 %s 상세설명 적용 (%s)", product_no, actor) return RedirectResponse( diff --git a/app/modules/cafe24/templates/cafe24/_editor.html b/app/modules/cafe24/templates/cafe24/_editor.html index bc9e37f..0447079 100644 --- a/app/modules/cafe24/templates/cafe24/_editor.html +++ b/app/modules/cafe24/templates/cafe24/_editor.html @@ -31,20 +31,7 @@ {% if desc %}

- {% if desc.separated_mobile %} - PC/모바일 분리 사용 상품입니다. - 모바일({{ desc.mobile_description | length }}자)은 아래 「모바일도 함께」 - 체크박스로 같은 내용을 반영할 수 있습니다. - {% if desc.mobile_differs %} - 지금 모바일 내용이 PC와 달라 기본 해제되어 있습니다 — - 체크하면 모바일이 PC와 같은 내용으로 덮어써집니다. - {% else %} - 현재 두 내용이 같아 기본 체크되어 있습니다. - {% endif %} - {% else %} - 모바일은 PC와 동일 설정이라 적용 시 함께 반영됩니다. - {% endif %} - {% if desc.mobile_differs %}현재 PC/모바일 내용이 다릅니다.{% endif %} + 적용하면 PC·모바일 상세설명이 같은 내용으로 반영됩니다.
소스는 태그마다 줄을 나눠 정리해서 보여주며, 적용하면 정리된 소스가 그대로 카페24에 저장됩니다. 줄바꿈·들여쓰기만 바뀌고 태그 구조는 그대로이며, @@ -62,17 +49,7 @@

- - PC 상세설명 HTML · {{ desc.description | length }}자 - {% if desc.separated_mobile %} - - {% endif %} - + 상세설명 HTML · {{ desc.description | length }}자 · PC/모바일 공통 @@ -98,17 +75,6 @@
-{% if desc.separated_mobile or desc.mobile_differs %} -
- 모바일 상세설명 HTML 보기 (읽기 전용 · {{ desc.mobile_description | length }}자) - -
- -
-
-{% endif %} -
버전 이력 {% if revisions %}({{ revisions | length }}건){% endif %} {% if revisions %} diff --git a/app/modules/cafe24/templates/cafe24/bulk.html b/app/modules/cafe24/templates/cafe24/bulk.html index 2a96e01..34feefe 100644 --- a/app/modules/cafe24/templates/cafe24/bulk.html +++ b/app/modules/cafe24/templates/cafe24/bulk.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} {% block content %} diff --git a/app/modules/cafe24/templates/cafe24/products.html b/app/modules/cafe24/templates/cafe24/products.html index 1087440..5beb313 100644 --- a/app/modules/cafe24/templates/cafe24/products.html +++ b/app/modules/cafe24/templates/cafe24/products.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} {% block content %} diff --git a/app/modules/cafe24/templates/cafe24/schedules.html b/app/modules/cafe24/templates/cafe24/schedules.html index 756915c..3d21c89 100644 --- a/app/modules/cafe24/templates/cafe24/schedules.html +++ b/app/modules/cafe24/templates/cafe24/schedules.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} {% block content %} diff --git a/app/modules/cafe24/templates/cafe24/system.html b/app/modules/cafe24/templates/cafe24/system.html index a053062..5e342bc 100644 --- a/app/modules/cafe24/templates/cafe24/system.html +++ b/app/modules/cafe24/templates/cafe24/system.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} {% block content %} diff --git a/docs/CAFE24_MODULE.md b/docs/CAFE24_MODULE.md index b7f8c33..d0b0cc8 100644 --- a/docs/CAFE24_MODULE.md +++ b/docs/CAFE24_MODULE.md @@ -71,11 +71,11 @@ app/modules/cafe24/ ← 상품관리 모듈 ``` ┌─ 550px ───────────────────┬───────── 남은 폭 전부 ─────────┐ │ 상품명 검색(한 줄) │ 상품 이름 · 번호 · 진열/판매 │ -│ ☐진열중 ☐판매중 │ PC 상세설명 HTML 편집기 │ -│ ── 목록(전체, 스크롤) ── │ (문법 강조 · 남은 높이 전부) │ -│ 번호 상품명 진열 판매 수정 │ [메모] [복사] [카페24에 적용] │ -│ (제목행 클릭 = 정렬) │ ▸ 모바일 HTML(분리 상품만) │ -│ │ ▸ 버전 이력 │ +│ ☑진열중 ☑판매중 (기본 체크) │ 상세설명 HTML 편집기 │ +│ ── 목록(전체, 스크롤) ── │ (PC/모바일 공통 · 문법 강조) │ +│ 번호 상품명 진열 판매 수정 │ [메모][복사][다시 읽기][적용] │ +│ (제목행 클릭 = 정렬) │ ▸ 버전 이력 │ +│ │ │ └───────────────────────────┴─────────────────────────────────┘ ``` @@ -163,7 +163,7 @@ app/modules/cafe24/ ← 상품관리 모듈 진행률을 보여주고, 한 건 실패가 나머지를 막지 않는다. - 적용 순서는 단건 편집과 같다: **현재값 재조회 → BACKUP → 교체 → PUT → MANUAL + 감사로그**(`action=bulk_style`). 지문 대조는 없다 — 방금 읽은 값을 바로 쓰기 때문. -- PC/모바일 분리 상품은 모바일도 함께 바꾼다. +- PC/모바일 분리 상품은 각 필드의 `