From 3476146102de8ce9c348db7c270b565d23a8592e Mon Sep 17 00:00:00 2001 From: king Date: Fri, 6 Nov 2026 10:36:42 +0900 Subject: [PATCH] =?UTF-8?q?style(=EB=9D=BC=EC=9D=B4=EB=B8=8C):=20=EC=98=A4?= =?UTF-8?q?=EB=A5=B8=EC=AA=BD=20=EB=8B=AC=EB=A0=A5=20=EA=B8=80=EC=9E=90=20?= =?UTF-8?q?=EA=B5=B5=EA=B2=8C,=20=EB=B0=A9=EC=86=A1=20=EC=9E=88=EB=8A=94?= =?UTF-8?q?=20=EB=82=A0=20=EC=A0=90=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 공용 erp-datepop mountRange 에 dayClass 옵션(없으면 예전 그대로) - 달력 화면이 보는 달 ±1년의 방송 날짜를 넘기고, 그 날에 초록 점 Co-Authored-By: Claude Opus 5.5 --- app/modules/inout/templates/inout/_datepop.html | 2 +- app/modules/live/CLAUDE.md | 2 +- app/modules/live/db.py | 7 +++++++ app/modules/live/router.py | 5 ++++- app/modules/live/templates/live/_scripts.html | 2 +- app/modules/live/templates/live/calendar.html | 5 +++-- app/modules/live/templates/live/index.html | 2 +- app/modules/live/templates/live/settings.html | 2 +- app/modules/vacation/templates/vacation/form.html | 2 +- app/modules/vacation/templates/vacation/options.html | 2 +- app/static/erp-datepop.js | 6 ++++-- app/static/live.css | 4 ++++ app/static/live.js | 3 +++ tests/js/live_calendar.browser.test.js | 9 +++++++++ tests/js/render_live.py | 3 +++ tests/test_live.py | 5 +++++ 16 files changed, 49 insertions(+), 12 deletions(-) diff --git a/app/modules/inout/templates/inout/_datepop.html b/app/modules/inout/templates/inout/_datepop.html index 76ad3d6..917e97e 100644 --- a/app/modules/inout/templates/inout/_datepop.html +++ b/app/modules/inout/templates/inout/_datepop.html @@ -2,4 +2,4 @@ - + diff --git a/app/modules/live/CLAUDE.md b/app/modules/live/CLAUDE.md index b14f009..6b2bbf0 100644 --- a/app/modules/live/CLAUDE.md +++ b/app/modules/live/CLAUDE.md @@ -20,7 +20,7 @@ 카드 머리 = **Tiktok Handle**(없으면 이름, 색 = 호스트 id 순 `HOST_COLORS`), SALES·COM·Fee. 카드 머리를 끌어 빈 칸으로 = 옮기기(`move`, 방송 길이 유지) · 다른 카드 위 = 맞바꾸기(`swap_with`, 날짜·시간 교환). 다시 그린 뒤 가로 위치 유지(sessionStorage). 빈 칸 + = 그 날짜·시간이 채워진 추가 창. **AD SPEND** = 날짜별 광고비 `live_daily_ad_spend`(마이그레이션 002, `POST /live/ad-spend`, 빈칸 = 지우기), ROAS = 판매금액 ÷ 광고비(광고비 없으면 `-`). 002 미적용이면 0 으로 보이고 저장만 안내. - **한 화면 맞춤**(2026-11-05) — 달력 보기는 넓은 화면(1101px 이상)에서 페이지 세로 스크롤 없음: `.lv-cal-wrap` 이 남은 높이를 쓰고, 풀HD 브라우저(세로 880px 이상)면 9개 시간 칸·합계 줄이 표 안 스크롤 없이 들어간다(카드가 한 칸에 겹치거나 창이 더 낮으면 표 안에서 스크롤). 카드·표 글자·칸 크기를 늘리면 `live_calendar.browser.test.js` 로 다시 확인. -- **오른쪽 달력**(2026-11-05, 달력 보기만, 세로 2분할 `.lv-split`, 240px = 공용 달력의 80%, 예전 날짜로 이동 줄 대신, 공용 `erp-datepop` `mountRange` + `locale` 옵션으로 영문) — 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지 — `endGap` 이 표 끝에 여백), 다른 달이면 그 달 화면으로 가서 맨 왼쪽(sessionStorage `lv_cal_jump`). 표시만 하고 요금·일수에 안 씀. 테스트 `tests/js/live_calendar.browser.test.js`(`render_live.py`). +- **오른쪽 달력**(2026-11-05, 달력 보기만, 세로 2분할 `.lv-split`, 240px = 공용 달력의 80%, 예전 날짜로 이동 줄 대신, 공용 `erp-datepop` `mountRange` + `locale` 옵션으로 영문) — 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지 — `endGap` 이 표 끝에 여백), 다른 달이면 그 달 화면으로 가서 맨 왼쪽(sessionStorage `lv_cal_jump`). 표시만 하고 요금·일수에 안 씀. 글자 굵게, **방송 있는 날 = 숫자 오른쪽 위 초록 점**(2026-11-06, `db.broadcast_days` 보는 달 ±1년 → `#lv-live-days`, 공용 `mountRange` 의 `dayClass` 옵션 → `has-live`). 테스트 `tests/js/live_calendar.browser.test.js`(`render_live.py`). **말레이시아 공휴일 표 = `holidays.py`**(쿠알라룸푸르 기준, 2026·2027, 대체휴일 포함) — 이슬람 명절은 달 관측으로 바뀔 수 있고, 2028 은 공고되면 손으로 추가. - **결과 이미지** — 방송 저장과 한 트랜잭션, JPG·PNG·WebP, 한 장 8MB, 방송당 10장(`store.MAX_IMAGES`). `prepare_photo` 가 실제 이미지 확인·긴 변 2400px·EXIF(GPS 등) 제거. BYTEA 저장. `GET /live/images/{id}`(권한 필요, 하루 private 캐시), `?thumb=1` = 160px JPEG(그때그때 만듦). 올린 뒤 내용이 안 바뀐다는 전제 — 이미지를 고치는 기능을 넣으면 캐시도 바꿀 것. diff --git a/app/modules/live/db.py b/app/modules/live/db.py index a0dd1f4..6334a40 100644 --- a/app/modules/live/db.py +++ b/app/modules/live/db.py @@ -99,6 +99,13 @@ class LiveDBStore: r["images"] = [i for i in images if i["broadcast_id"] == r["id"]] return rows + def broadcast_days(self, start: date, end: date) -> list[str]: + """start 이상 end 미만 방송이 있는 날(ISO) — 오른쪽 달력 점.""" + with self._pool.connection() as conn: + rows = conn.execute("SELECT DISTINCT broadcast_date FROM live_broadcasts WHERE broadcast_date >= %s AND broadcast_date < %s ORDER BY 1", + (start, end)).fetchall() + return [r["broadcast_date"].isoformat() for r in rows] + def save_broadcast(self, broadcast_id: int | None, values: dict[str, Any], images: list[dict[str, Any]], *, by: str) -> int: """방송·이미지를 한 트랜잭션으로. 사용 안 함 호스트는 이미 그 호스트인 방송을 고칠 때만 허용.""" with self._pool.connection() as conn, conn.transaction(): diff --git a/app/modules/live/router.py b/app/modules/live/router.py index 515331b..da1cc84 100644 --- a/app/modules/live/router.py +++ b/app/modules/live/router.py @@ -15,6 +15,7 @@ DB: LIVE_DB_URL(live_db) — 없으면 "설정 필요" 안내. from __future__ import annotations +from datetime import timedelta from pathlib import PurePath from typing import Any @@ -161,7 +162,9 @@ def calendar(request: Request, month: str = "") -> Any: cal = store.build_calendar(span, st.list_broadcasts(span["start"], span["end"]), st.ad_spends(span["start"], span["end"]), today, lang) return _render(request, "live/calendar.html", user, {"view": "calendar", "span": span, "cal": cal, "hosts": st.host_choices(), "accounts": st.account_choices(), "max_images": store.MAX_IMAGES, - "my_holidays": holidays.holiday_names(lang)}) + "my_holidays": holidays.holiday_names(lang), + # 오른쪽 달력 점 — 앞뒤로 넘겨 볼 달까지(보는 달 ±1년) + "live_days": st.broadcast_days(span["start"] - timedelta(days=366), span["end"] + timedelta(days=366))}) @router.post("/broadcasts/{broadcast_id}/move") diff --git a/app/modules/live/templates/live/_scripts.html b/app/modules/live/templates/live/_scripts.html index 0967581..397f6e0 100644 --- a/app/modules/live/templates/live/_scripts.html +++ b/app/modules/live/templates/live/_scripts.html @@ -1,2 +1,2 @@ - + diff --git a/app/modules/live/templates/live/calendar.html b/app/modules/live/templates/live/calendar.html index f35107e..94354bd 100644 --- a/app/modules/live/templates/live/calendar.html +++ b/app/modules/live/templates/live/calendar.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 달력 보기(2026-11-04) — 줄 = 2시간 칸, 열 = 날짜, 맨 아래 = 날짜별 합계. 카드 머리 = 호스트 간단한 이름 + 그 방송의 틱톡 계정. 카드 머리를 끌어 빈 칸으로 옮기거나 다른 카드 위에 놓아 맞바꾼다(live.js). 문구 = t()(i18n.py), 영문은 CSS 로 대문자(받은 화면과 같게). -#} -{% block head_extra %} +{% block head_extra %} {% endblock %} @@ -86,5 +86,6 @@ {% endblock %} {% block scripts %} - + + {% include "live/_scripts.html" %}{% endblock %} diff --git a/app/modules/live/templates/live/index.html b/app/modules/live/templates/live/index.html index f2e8725..110cf1b 100644 --- a/app/modules/live/templates/live/index.html +++ b/app/modules/live/templates/live/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 스케줄표(2026-11-04) — 달마다 방송 목록. 추가·고치기 창은 달력과 공용(_dialog.html, live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/live/templates/live/settings.html b/app/modules/live/templates/live/settings.html index ec5a33b..5e4c916 100644 --- a/app/modules/live/templates/live/settings.html +++ b/app/modules/live/templates/live/settings.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 설정(2026-11-04) — 호스트 정보. 계좌 등 개인정보·지우기는 ERP 관리자만(router.settings), 칩 권한자는 이름·상태만 보임 — `live_host` = 새 등록, `live_host_edit` = 고치기(개인정보는 빈칸으로 열림, 비워 두면 그대로). 추가·고치기는 같은 창(live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {#- 쇼핑몰(005, store.PLATFORMS) — 로고는 말레이시아 배송 모듈 이미지 -#} diff --git a/app/modules/vacation/templates/vacation/form.html b/app/modules/vacation/templates/vacation/form.html index 494c106..29e81ac 100644 --- a/app/modules/vacation/templates/vacation/form.html +++ b/app/modules/vacation/templates/vacation/form.html @@ -134,5 +134,5 @@ {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/app/modules/vacation/templates/vacation/options.html b/app/modules/vacation/templates/vacation/options.html index 0930b9f..3b5a1d2 100644 --- a/app/modules/vacation/templates/vacation/options.html +++ b/app/modules/vacation/templates/vacation/options.html @@ -149,5 +149,5 @@
{% endblock %} -{% block scripts %} +{% block scripts %} {% endblock %} diff --git a/app/static/erp-datepop.js b/app/static/erp-datepop.js index fec7884..5a17b48 100644 --- a/app/static/erp-datepop.js +++ b/app/static/erp-datepop.js @@ -356,7 +356,7 @@ // 화면에 붙박이는 기간 달력(2026-11-02, 휴가 신청) — 팝업과 같은 달력 서식(.pj-dp-*). // 첫 클릭 = 시작일(동그라미), 다음 클릭 = 종료일(둥근 막대), 그다음 클릭 = 새로 시작. 시작일보다 앞을 누르면 그 날이 새 시작일. - // opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end), locale }. 반환 { set(start, end) } + // opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end), locale, dayClass(iso) — 칸에 더할 클래스 목록(라이브 = 방송 있는 날) }. 반환 { set(start, end) } function mountRange(box, opts) { const holidays = opts.holidays || {}; const today = isoToday(); @@ -380,7 +380,9 @@ '' + '' + esc(loc.title ? loc.title(viewY, viewM) : viewY + "년 " + (viewM + 1) + "월") + "" + '' + - "" + gridHtml(viewY, viewM, holidays, today, bandClasses, opts.locale); + "" + gridHtml(viewY, viewM, holidays, today, function (iso, d) { + return opts.dayClass ? bandClasses(iso, d).concat(opts.dayClass(iso)) : bandClasses(iso, d); + }, opts.locale); } box.addEventListener("click", function (e) { const nav = e.target.closest(".pj-dp-navbtn"); diff --git a/app/static/live.css b/app/static/live.css index 52f0a35..5dc5d1a 100644 --- a/app/static/live.css +++ b/app/static/live.css @@ -68,6 +68,10 @@ .lv-side-cal .pj-dp-num { height: 27px; } .lv-side-cal .pj-dp-day.has-hol { height: 37px; } .lv-side-cal .pj-dp-hol { margin-top: -2px; font-size: 8px; } +/* 글자 굵게(오늘은 공용 800 그대로), 방송 있는 날 = 숫자 원 오른쪽 위 초록 점 */ +.lv-side-cal .pj-dp-title, .lv-side-cal .pj-dp-wd, .lv-side-cal .pj-dp-day:not(.is-today), .lv-side-cal .pj-dp-hol { font-weight: 700; } +.lv-side-cal .pj-dp-day.has-live::after { content: ""; position: absolute; top: 1px; left: calc(50% + 7px); width: 6px; height: 6px; border-radius: 50%; background: #16a34a; z-index: 1; } +.lv-side-cal .pj-dp-day.is-out.has-live::after { opacity: .4; } .lv-cal-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; } .lv-cal { border-collapse: separate; border-spacing: 0; min-width: max-content; } .lv-cal th, .lv-cal td { border-right: 1px solid #e3e6eb; border-bottom: 1px solid #e3e6eb; } diff --git a/app/static/live.js b/app/static/live.js index e62a4db..50507aa 100644 --- a/app/static/live.js +++ b/app/static/live.js @@ -170,9 +170,12 @@ if (sideBox && window.ErpDatePop) { let holidays = {}; try { holidays = JSON.parse(document.getElementById("lv-my-holidays").textContent); } catch (_) {} + let liveDays = {}; // 방송 있는 날 → 점 + try { JSON.parse(document.getElementById("lv-live-days").textContent).forEach(function (iso) { liveDays[iso] = true; }); } catch (_) {} const english = document.querySelector(".lv").lang === "en"; window.ErpDatePop.mountRange(sideBox, { start: shownDay, end: shownDay, holidays: holidays, single: function () { return true; }, + dayClass: function (iso) { return liveDays[iso] ? ["has-live"] : []; }, locale: english ? { weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], prev: "Previous month", next: "Next month", title: function (y, m) { return new Date(y, m, 1).toLocaleString("en", { month: "long" }) + " " + y; }, diff --git a/tests/js/live_calendar.browser.test.js b/tests/js/live_calendar.browser.test.js index 3e6d800..fc3a688 100644 --- a/tests/js/live_calendar.browser.test.js +++ b/tests/js/live_calendar.browser.test.js @@ -84,6 +84,15 @@ function check(name, cond, extra) { await p.waitForTimeout(100); check("디파발리 = 빨강·이름·말풍선", (await day("2026-11-08").getAttribute("class")).includes("has-hol") && (await day("2026-11-08").getAttribute("title")) === "디파발리"); check("대체휴일 표시", (await day("2026-11-09").innerText()).includes("대체휴일") && (await day("2026-11-09").getAttribute("title")) === "디파발리 대체", await day("2026-11-09").innerText()); + const marked = await p.locator("#lv-side-cal .has-live").evaluateAll(function (els) { return els.map(function (e) { return e.dataset.iso; }); }); + // 2026-11 달력은 11/1(일)부터라 10/30 칸은 없음, 12/3 = 다음 달 칸 + check("방송 있는 날 = 점(다른 달 날짜 포함)", JSON.stringify(marked) === JSON.stringify(["2026-11-05", "2026-11-20", "2026-12-03"]), marked); + const dot = await day("2026-11-20").evaluate(function (el) { const c = getComputedStyle(el, "::after"); return c.width + "|" + c.backgroundColor; }); + check("점 모양", dot === "6px|rgb(22, 163, 74)", dot); + const bold = await p.evaluate(function () { + return ["#lv-side-cal .pj-dp-title", "#lv-side-cal .pj-dp-wd", '#lv-side-cal [data-iso="2026-11-17"]'].map(function (s) { return getComputedStyle(document.querySelector(s)).fontWeight; }); + }); + check("오른쪽 달력 글자 굵게", bold.every(function (w) { return +w >= 700; }), bold); await p.screenshot({ path: path.join(__dirname, ".out", "live_side_cal.png") }); await day("2026-11-17").click(); diff --git a/tests/js/render_live.py b/tests/js/render_live.py index f19248f..c750e44 100644 --- a/tests/js/render_live.py +++ b/tests/js/render_live.py @@ -43,6 +43,9 @@ class Fake: def ad_spends(self, start, end): return {} + def broadcast_days(self, start, end): + return ["2026-10-30", "2026-11-05", "2026-11-20", "2026-12-03"] # 오른쪽 달력 점 — 다른 달 날짜도 + def account_choices(self): return ["MainAccount"] diff --git a/tests/test_live.py b/tests/test_live.py index 25e634c..173e477 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -400,6 +400,9 @@ class Fake: return [] def ad_spends(self, start, end): return {} + def broadcast_days(self, start, end): + assert (start.isoformat(), end.isoformat()) == ("2025-10-31", "2027-12-02"), (start, end) # 보는 달 ±1년 + return ["2026-11-05"] def account_choices(self): return [] main.app.state.live_store = Fake() @@ -412,6 +415,7 @@ def body(c): page = c.get("/live/calendar?month=2026-11").text assert 'id="lv-side-cal"' in page and "/static/erp-datepop.js" in page assert names(page)["2026-11-09"] == "디파발리 대체" + assert '' in page c.cookies.set("live_lang", "en") assert names(c.get("/live/calendar?month=2026-11").text)["2026-11-09"] == "Deepavali (Replacement)" print("OK") @@ -529,6 +533,7 @@ def body(c): c.post("/live/broadcasts", data={**show, "id": bid, "sales_amount": "48", "start_time": "12:00", "end_time": "14:00", "broadcast_date": "2031-03-05"}) cal = c.get("/live/calendar?month=2031-03").text assert "날짜로 이동" not in cal and "토요일" in cal and "12:00 - 14:00" in cal and "2시간 (기본 RM50)" in cal + assert '"2031-03-05"' in cal.split('id="lv-live-days">')[1].split("")[0] # 오른쪽 달력 점 assert 'S%s@siti.%s' % (tag, tag) in cal and "RM54.80" in cal and ">4.80" in cal # ── 영문: 화면 세 개 모두 한글 없음(입력한 데이터 제외)·날짜·오류·권한 문구 ──