Update teacher profiles and record summaries
This commit is contained in:
+20
-3
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user