From 4b87603e06e6365c919254f04373a2f5a2923ac3 Mon Sep 17 00:00:00 2001 From: ahtlon Date: Mon, 27 Jul 2026 16:40:45 +0200 Subject: [PATCH] [AA] fix patching AA with oneshots --- app/controllers/aaManager.py | 6 +++++- app/model/models.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/aaManager.py b/app/controllers/aaManager.py index a697e43..e256051 100644 --- a/app/controllers/aaManager.py +++ b/app/controllers/aaManager.py @@ -75,12 +75,16 @@ def change_accessauth(*, db: Session = Depends(get_session), aa_id: int, aa: Acc db_aa = db.get(AccessAuthorizationDB, aa_id) if db_aa is None: raise HTTPException(status_code=404, detail="AccessAuthorization not found") - aa_data = aa.model_dump(exclude_unset=True) + aa_data = aa.model_dump(exclude_unset=True, exclude_none=True) if "timetables" in aa_data and aa_data["timetables"] is not None: db_aa.timetables.clear() timetables = [Timetable.model_validate(t) for t in aa_data["timetables"]] db_aa.timetables = timetables aa_data.pop("timetables") + if "oneshot" in aa_data and aa_data["oneshot"] is not None: + oneshot = OneShotAccess.model_validate(aa_data["oneshot"]) + db_aa.oneshot = oneshot + aa_data.pop("oneshot") db_aa.sqlmodel_update(aa_data) return add_and_refresh(db, db_aa) diff --git a/app/model/models.py b/app/model/models.py index cced809..b198e15 100644 --- a/app/model/models.py +++ b/app/model/models.py @@ -108,8 +108,10 @@ class AccessAuthorizationResponse(AccessAuthorizationBase): class AccessAuthorizationUpdate(Base): name: str | None = None + type: Literal["timetable", "oneshot", "somefuturespec"] | None = None is_active: bool | None = None timetables: List["TimetableCreate"] | None = None + oneshot: OneShotAccessBase | None = None #### Card