From e45abb5c55a1c42e38ae8d0c51e87f4dd67008d2 Mon Sep 17 00:00:00 2001 From: ahtlon Date: Mon, 27 Jul 2026 15:33:39 +0200 Subject: [PATCH] [AA] fix the db insert --- app/controllers/aaManager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/aaManager.py b/app/controllers/aaManager.py index 4f9a1d6..a697e43 100644 --- a/app/controllers/aaManager.py +++ b/app/controllers/aaManager.py @@ -15,11 +15,18 @@ aa_router = APIRouter(prefix="/api/v1/aa", tags=["AccessAuth"]) @aa_router.post("/", response_model=AccessAuthorizationResponse) def add_accessauth(*, db: Session = Depends(get_session), aa: AccessAuthorizationCreate, admin: bool = Depends(auth_is_admin)): logger.info(f"Creating accessauth with data: {aa}") - timetables = [Timetable.model_validate(t) for t in aa.timetables] + if aa.timetables is not []: + timetables = [Timetable.model_validate(t) for t in aa.timetables] + else: timetables = [] + if aa.oneshot is not None: + oneshot = OneShotAccess.model_validate(aa.oneshot) + else: oneshot = None db_aa = AccessAuthorizationDB( name=aa.name, + type=aa.type, is_active=aa.is_active, - timetables=timetables + timetables=timetables, + oneshot=oneshot ) return add_and_refresh(db, db_aa)