feat: admin 주제 편집 — form mode (4 카테고리 expander)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
55
app.py
55
app.py
@@ -659,6 +659,61 @@ def render_admin():
|
||||
set_voting_open(True)
|
||||
st.rerun()
|
||||
|
||||
st.divider()
|
||||
st.subheader("🗒 주제 편집")
|
||||
cur_topics = get_topics()
|
||||
if not cur_topics:
|
||||
st.warning("주제 시드 비어있음. 컨테이너 재시작 시 시드 자동 적용됨.")
|
||||
else:
|
||||
edit_mode = st.radio(
|
||||
"편집 모드", ["Form", "JSON 직접 편집"], horizontal=True, key="topics_mode"
|
||||
)
|
||||
|
||||
if edit_mode == "Form":
|
||||
with st.form("topics_form"):
|
||||
new_cats = []
|
||||
for cat in cur_topics:
|
||||
cid = cat.get("id", "T?")
|
||||
with st.expander(f"{cid}. {cat.get('title', '')}", expanded=False):
|
||||
title = st.text_input(
|
||||
"title", cat.get("title", ""), key=f"t_{cid}_title"
|
||||
)
|
||||
tagline = st.text_input(
|
||||
"tagline", cat.get("tagline", ""), key=f"t_{cid}_tagline"
|
||||
)
|
||||
tone = st.text_input(
|
||||
"tone", cat.get("tone", ""), key=f"t_{cid}_tone"
|
||||
)
|
||||
items = []
|
||||
existing_items = cat.get("items", [])
|
||||
# 10개 input 자리 (빈 자리 포함)
|
||||
padded = list(existing_items) + [""] * (10 - len(existing_items))
|
||||
for i in range(10):
|
||||
items.append(
|
||||
st.text_input(
|
||||
f"주제 {i + 1}",
|
||||
padded[i] if i < len(padded) else "",
|
||||
key=f"t_{cid}_item_{i}",
|
||||
)
|
||||
)
|
||||
items = [x for x in items if x.strip()]
|
||||
new_cats.append(
|
||||
{
|
||||
"id": cid,
|
||||
"title": title.strip(),
|
||||
"tagline": tagline.strip(),
|
||||
"tone": tone.strip(),
|
||||
"items": items,
|
||||
}
|
||||
)
|
||||
if st.form_submit_button("주제 저장"):
|
||||
update_topics(new_cats)
|
||||
st.success("저장됨. 큰 화면 다음 갱신 시 반영.")
|
||||
st.rerun()
|
||||
# JSON 모드는 T14에서 추가 (else branch는 placeholder)
|
||||
else:
|
||||
st.info("Task 14에서 JSON 직접 편집 모드 추가됨.")
|
||||
|
||||
st.divider()
|
||||
|
||||
PARTS = get_participants()
|
||||
|
||||
Reference in New Issue
Block a user