Update teacher profiles and record summaries

This commit is contained in:
Codex
2026-06-16 01:09:51 +08:00
parent a7fbe91266
commit 2785f3eb41
18 changed files with 1088 additions and 40 deletions
+20 -3
View File
@@ -6,9 +6,9 @@ from pathlib import Path
from fastapi import HTTPException, Request
from pydantic import ValidationError
from .config import ACCOUNTS_PATH, CLASSNOTES_PATH
from .data import Account, Payment, read_accounts, read_classnotes
from .schemas import AccountPayload, RegisterLinesPayload
from .config import ACCOUNTS_PATH, CLASSNOTES_PATH, TEACHERS_PATH
from .data import Account, Payment, Teacher, read_accounts, read_classnotes, read_teachers
from .schemas import AccountPayload, RegisterLinesPayload, TeacherPayload
async def read_register_payload(request: Request) -> RegisterLinesPayload:
@@ -49,6 +49,12 @@ def load_accounts():
return read_accounts(ACCOUNTS_PATH)
def load_teachers():
if not TEACHERS_PATH.exists():
return []
return read_teachers(TEACHERS_PATH)
def file_meta(path: Path) -> dict:
if not path.exists():
return {"exists": False, "path": str(path)}
@@ -70,3 +76,14 @@ def payload_to_account(payload: AccountPayload, student_id: str | None = None) -
account_status=payload.account_status,
note=payload.note,
)
def payload_to_teacher(payload: TeacherPayload, teacher_id: str | None = None) -> Teacher:
return Teacher(
teacher_id=teacher_id if teacher_id is not None else payload.teacher_id,
name=payload.name,
alias=payload.alias,
subjects=payload.subjects,
status=payload.status,
note=payload.note,
)