feat(라이브): 틱톡 계정을 호스트에서 방송으로 옮김
호스트가 메인 계정 외 다른 계정에서도 방송하므로 호스트 설정에서 틱톡 핸들을 빼고 방송 추가·고치기 창에서 방송마다 입력한다. 쓴 적 있는 계정을 입력 제안으로 보여 준다. 마이그레이션 003: live_broadcasts.tiktok_handle 추가, 기존 방송에 호스트의 지금 계정 복사. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,9 +25,10 @@ _CENT = Decimal("0.01")
|
||||
_WEEKDAYS = ("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY")
|
||||
_MONTHS = ("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")
|
||||
|
||||
HOST_LIMITS = {"full_name": 200, "phone": 40, "email": 254, "address": 500, "bank_name": 100, "bank_account": 40, "tiktok_handle": 64}
|
||||
HOST_LIMITS = {"full_name": 200, "phone": 40, "email": 254, "address": 500, "bank_name": 100, "bank_account": 40}
|
||||
HANDLE_LIMIT = 64
|
||||
_LABELS = {"full_name": "이름 (IC 기준)", "phone": "전화번호", "email": "이메일", "address": "주소", "bank_name": "은행명",
|
||||
"bank_account": "계좌번호", "tiktok_handle": "틱톡 핸들"}
|
||||
"bank_account": "계좌번호"}
|
||||
_EMAIL_RE = re.compile(r"^[A-Za-z0-9._%+\-']+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$")
|
||||
_PHONE_RE = re.compile(r"^\+?[0-9()\-\s]+$")
|
||||
_ACCOUNT_RE = re.compile(r"^[0-9\-\s]+$")
|
||||
@@ -46,7 +47,6 @@ def clean_handle(raw: Any) -> str:
|
||||
def clean_host(values: dict[str, Any]) -> dict[str, str]:
|
||||
"""호스트 입력 검사 — 이름만 필수, 나머지는 있으면 형식 확인. 틀리면 ValueError."""
|
||||
out = {k: str(values.get(k) or "").strip() for k in HOST_LIMITS}
|
||||
out["tiktok_handle"] = clean_handle(values.get("tiktok_handle"))
|
||||
if not out["full_name"]:
|
||||
raise LiveError("이름 (IC 기준)을 입력하세요.")
|
||||
for key, limit in HOST_LIMITS.items():
|
||||
@@ -58,8 +58,6 @@ def clean_host(values: dict[str, Any]) -> dict[str, str]:
|
||||
raise LiveError("전화번호는 숫자·+·-·괄호만 입력하세요.")
|
||||
if out["bank_account"] and not _ACCOUNT_RE.match(out["bank_account"]):
|
||||
raise LiveError("계좌번호는 숫자·-만 입력하세요.")
|
||||
if out["tiktok_handle"] and not _HANDLE_RE.match(out["tiktok_handle"]):
|
||||
raise LiveError("틱톡 핸들은 영문·숫자·밑줄·점만 입력하세요.")
|
||||
return out
|
||||
|
||||
|
||||
@@ -107,8 +105,13 @@ def clean_broadcast(values: dict[str, Any]) -> dict[str, Any]:
|
||||
end = _parse_time(values.get("end_time"), label="끝 시간", required=True)
|
||||
if start == end:
|
||||
raise LiveError("끝 시간이 시작 시간과 같습니다.")
|
||||
handle = clean_handle(values.get("tiktok_handle"))
|
||||
if len(handle) > HANDLE_LIMIT:
|
||||
raise LiveError("{label} 이(가) 너무 깁니다({limit}자까지).", label="틱톡 핸들", limit=HANDLE_LIMIT)
|
||||
if handle and not _HANDLE_RE.match(handle):
|
||||
raise LiveError("틱톡 핸들은 영문·숫자·밑줄·점만 입력하세요.")
|
||||
return {"host_id": int(host), "broadcast_date": day, "start_time": start, "end_time": end,
|
||||
"venue": venue, "sales_amount": parse_money(values.get("sales_amount"))}
|
||||
"venue": venue, "tiktok_handle": handle, "sales_amount": parse_money(values.get("sales_amount"))}
|
||||
|
||||
|
||||
def parse_move(day: Any, start: Any) -> tuple[date, time]:
|
||||
@@ -158,7 +161,7 @@ def broadcast_view(b: dict[str, Any], lang: str = "ko") -> dict[str, Any]:
|
||||
"card_fee": fmt_short(pay["fee"]),
|
||||
"edit": {"id": b["id"], "host_id": b["host_id"], "broadcast_date": b["broadcast_date"].isoformat(),
|
||||
"start_time": f"{b['start_time']:%H:%M}", "end_time": f"{b['end_time']:%H:%M}" if b["end_time"] else "",
|
||||
"venue": b["venue"], "sales_amount": f"{b['sales_amount']:.2f}" if b["sales_amount"] is not None else "",
|
||||
"venue": b["venue"], "tiktok_handle": b["tiktok_handle"], "sales_amount": f"{b['sales_amount']:.2f}" if b["sales_amount"] is not None else "",
|
||||
"images": [{"id": i["id"], "filename": i["filename"]} for i in b["images"]]},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user