sql_app: init_db: Added a link (allowance)

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-06-07 15:02:33 +03:00
parent 6850823ae8
commit 4789b2778c
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -16,6 +16,7 @@ def init_user():
token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15)) token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15))
res = crud.set_user_last_token(db, user.username, token) res = crud.set_user_last_token(db, user.username, token)
user_exists = None
user = schemas.UserCreate(email="osama@mail.none", user = schemas.UserCreate(email="osama@mail.none",
username="Osama", username="Osama",
password=config('first_user_pass')) password=config('first_user_pass'))
@ -25,6 +26,7 @@ def init_user():
token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15)) token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15))
res = crud.set_user_last_token(db, user.username, token) res = crud.set_user_last_token(db, user.username, token)
user_exists = None
user = schemas.UserCreate(email="Hussain@mail.none", user = schemas.UserCreate(email="Hussain@mail.none",
username="Hussain", username="Hussain",
password=config('first_user_pass')) password=config('first_user_pass'))
@ -34,6 +36,7 @@ def init_user():
token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15)) token = auth_helper.create_access_token(data={"sub": user.username}, expires_delta=timedelta(minutes=15))
res = crud.set_user_last_token(db, user.username, token) res = crud.set_user_last_token(db, user.username, token)
user_exists = None
user = schemas.UserCreate(email="Assad@mail.none", user = schemas.UserCreate(email="Assad@mail.none",
username="Assad", username="Assad",
password=config('first_user_pass')) password=config('first_user_pass'))
@ -57,8 +60,12 @@ def init_monitor():
if monitor_exists: return if monitor_exists: return
crud.create_iot_entity(db, iot_monitor) crud.create_iot_entity(db, iot_monitor)
def init_allowance():
crud.create_user_link_to_iot(db, 1, 1)
def init(): def init():
init_user() init_user()
init_door() init_door()
init_monitor() init_monitor()
init_allowance()