feat: 增加公告栏并让用户自选学时判断

This commit is contained in:
Nixevol
2026-11-19 04:08:30 +08:00
parent 3fe6d4c111
commit 4d4fe224bc
20 changed files with 789 additions and 64 deletions
+12 -5
View File
@@ -135,7 +135,14 @@ def _persist_locked(db: Session, employee_id: str, password: str | None, client:
client.authorize(profile)
account = db.get(Account, employee_id)
if account is None:
account = Account(employee_id=employee_id, password_cipher="", credential_cipher="")
from admin.settings import hours_source_of
account = Account(
employee_id=employee_id,
password_cipher="",
credential_cipher="",
hours_source=hours_source_of(),
)
db.add(account)
if password is None:
stored = ""
@@ -411,10 +418,10 @@ def fetch_study_history(db: Session, employee_id: str, client_factory=EunivClien
def _apply_hours_source(client, summary: dict, items: list | None = None) -> dict:
from admin.settings import hours_source_of
from admin.settings import source_for_employee
data = dict(summary)
source = hours_source_of()
source = source_for_employee(str(getattr(client, "login_name", "") or ""))
data["hours_source"] = source
data["official_month_hours"] = data.get("month_hours")
if source != "history":
@@ -839,9 +846,9 @@ def start_credential_refresh() -> _RefreshGate:
def _month_hours(client) -> str:
from admin.settings import hours_source_of
from admin.settings import source_for_employee
if hours_source_of() == "history":
if source_for_employee(str(getattr(client, "login_name", "") or "")) == "history":
reader = getattr(client, "month_history_minutes", None)
if reader is None:
return ""