Claude commited on
Commit
d401caa
·
unverified ·
1 Parent(s): bd2e763

Feat: 관리자 페이지에 교사 계정 신청 거절 기능 추가

Browse files

거절 시 해당 계정 레코드를 삭제하며, 교사는 동일 ID로 재신청 가능.
승인/거절 버튼을 한 행에 나란히 배치.

https://claude.ai/code/session_01VubVHht1kvabfdfFR1weKs

Files changed (2) hide show
  1. db.py +7 -0
  2. views/admin.py +12 -5
db.py CHANGED
@@ -482,3 +482,10 @@ def approve_teacher_account(supabase: Client, account_id: int, approved_at: str)
482
  supabase.table("teacher_accounts").update({"is_approved": True, "approved_at": approved_at}).eq("id", account_id),
483
  fail_message="교사 계정 승인 실패",
484
  )
 
 
 
 
 
 
 
 
482
  supabase.table("teacher_accounts").update({"is_approved": True, "approved_at": approved_at}).eq("id", account_id),
483
  fail_message="교사 계정 승인 실패",
484
  )
485
+
486
+
487
+ def reject_teacher_account(supabase: Client, account_id: int):
488
+ return execute_query(
489
+ supabase.table("teacher_accounts").delete().eq("id", account_id),
490
+ fail_message="교사 계정 거절 실패",
491
+ )
views/admin.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from db import fetch_pending_teacher_accounts, approve_teacher_account
3
  from utils import format_kst_datetime, get_kst_now_str
4
 
5
 
@@ -13,16 +13,23 @@ def render_admin_approval_panel(supabase):
13
  acc_id = pending.get("id")
14
  pending_teacher_id = pending.get("teacher_id", "")
15
  requested_at = pending.get("requested_at", "") or "-"
16
- c_left, c_right = st.columns([3, 2])
17
- with c_left:
18
  st.write(f"ID: {pending_teacher_id}")
19
- with c_right:
20
  st.caption(f"신청 시각: {format_kst_datetime(requested_at)}")
21
- if st.button("승인", key=f"approve_{acc_id}"):
 
22
  res = approve_teacher_account(supabase, acc_id, get_kst_now_str())
23
  if res is not None:
24
  st.success(f"{pending_teacher_id} 계정을 승인했습니다.")
25
  st.rerun()
 
 
 
 
 
 
26
 
27
 
28
  def render_admin_page(supabase, user_role, teacher_auth, admin_auth):
 
1
  import streamlit as st
2
+ from db import fetch_pending_teacher_accounts, approve_teacher_account, reject_teacher_account
3
  from utils import format_kst_datetime, get_kst_now_str
4
 
5
 
 
13
  acc_id = pending.get("id")
14
  pending_teacher_id = pending.get("teacher_id", "")
15
  requested_at = pending.get("requested_at", "") or "-"
16
+ c_id, c_date, c_approve, c_reject = st.columns([3, 2, 1, 1])
17
+ with c_id:
18
  st.write(f"ID: {pending_teacher_id}")
19
+ with c_date:
20
  st.caption(f"신청 시각: {format_kst_datetime(requested_at)}")
21
+ with c_approve:
22
+ if st.button("✅ 승인", key=f"approve_{acc_id}", use_container_width=True):
23
  res = approve_teacher_account(supabase, acc_id, get_kst_now_str())
24
  if res is not None:
25
  st.success(f"{pending_teacher_id} 계정을 승인했습니다.")
26
  st.rerun()
27
+ with c_reject:
28
+ if st.button("❌ 거절", key=f"reject_{acc_id}", use_container_width=True, type="secondary"):
29
+ res = reject_teacher_account(supabase, acc_id)
30
+ if res is not None:
31
+ st.warning(f"{pending_teacher_id} 계정 신청을 거절했습니다.")
32
+ st.rerun()
33
 
34
 
35
  def render_admin_page(supabase, user_role, teacher_auth, admin_auth):