[AA] fix the db insert

This commit is contained in:
2026-07-27 15:33:39 +02:00
committed by ahtlon
parent 47b84a097c
commit e45abb5c55

View File

@@ -15,11 +15,18 @@ aa_router = APIRouter(prefix="/api/v1/aa", tags=["AccessAuth"])
@aa_router.post("/", response_model=AccessAuthorizationResponse) @aa_router.post("/", response_model=AccessAuthorizationResponse)
def add_accessauth(*, db: Session = Depends(get_session), aa: AccessAuthorizationCreate, admin: bool = Depends(auth_is_admin)): def add_accessauth(*, db: Session = Depends(get_session), aa: AccessAuthorizationCreate, admin: bool = Depends(auth_is_admin)):
logger.info(f"Creating accessauth with data: {aa}") logger.info(f"Creating accessauth with data: {aa}")
if aa.timetables is not []:
timetables = [Timetable.model_validate(t) for t in aa.timetables] 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( db_aa = AccessAuthorizationDB(
name=aa.name, name=aa.name,
type=aa.type,
is_active=aa.is_active, is_active=aa.is_active,
timetables=timetables timetables=timetables,
oneshot=oneshot
) )
return add_and_refresh(db, db_aa) return add_and_refresh(db, db_aa)