Change accessauth, timetable model #16

Merged
ahtlon merged 6 commits from change_tt_model into master 2026-07-27 17:19:59 +02:00
Showing only changes of commit e45abb5c55 - Show all commits
+9 -2
View File
@@ -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)