Update teacher profiles and record summaries
This commit is contained in:
@@ -14,10 +14,12 @@ from ..config import (
|
||||
from ..data import (
|
||||
append_operation_log,
|
||||
approve_admin_task,
|
||||
delete_course_summary,
|
||||
list_admin_tasks,
|
||||
list_operation_logs,
|
||||
query_course_summaries,
|
||||
reject_admin_task,
|
||||
update_course_summary_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -61,6 +63,7 @@ def admin_course_summaries(
|
||||
subject: str = Query(""),
|
||||
date_from: str = Query(""),
|
||||
date_to: str = Query(""),
|
||||
missing_time: bool = Query(False),
|
||||
limit: int = Query(200, ge=1, le=1000),
|
||||
_user: str = Depends(verify_admin_auth),
|
||||
):
|
||||
@@ -73,6 +76,7 @@ def admin_course_summaries(
|
||||
subject=subject,
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
missing_time=missing_time,
|
||||
limit=limit,
|
||||
)
|
||||
except ValueError as exc:
|
||||
@@ -117,3 +121,38 @@ def admin_reject_task(task_id: int, _user: str = Depends(verify_admin_auth)):
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
return {"ok": True, "task": task}
|
||||
|
||||
|
||||
@router.post("/api/admin/course-summaries/{summary_id}/time")
|
||||
def admin_update_course_summary_time(summary_id: str, payload: dict, _user: str = Depends(verify_admin_auth)):
|
||||
try:
|
||||
with write_lock:
|
||||
result = update_course_summary_time(COURSE_SUMMARIES_ROOT, summary_id, str(payload.get("time_range") or ""))
|
||||
append_operation_log(
|
||||
OPERATION_LOGS_PATH,
|
||||
"admin_course_summary_update_time",
|
||||
"updated",
|
||||
summary_id=summary_id,
|
||||
time_range=str(payload.get("time_range") or ""),
|
||||
backup_id=str(result.get("backup_id") or ""),
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
return {"ok": True, **result}
|
||||
|
||||
|
||||
@router.delete("/api/admin/course-summaries/{summary_id}")
|
||||
def admin_delete_course_summary(summary_id: str, _user: str = Depends(verify_admin_auth)):
|
||||
try:
|
||||
with write_lock:
|
||||
result = delete_course_summary(COURSE_SUMMARIES_ROOT, summary_id)
|
||||
append_operation_log(
|
||||
OPERATION_LOGS_PATH,
|
||||
"admin_course_summary_delete",
|
||||
"deleted",
|
||||
summary_id=summary_id,
|
||||
backup_id=str(result.get("backup_id") or ""),
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
return {"ok": True, **result}
|
||||
|
||||
Reference in New Issue
Block a user