prod-wag-backend-automate-s.../ApiServices/DealerService/app.py

78 lines
3.0 KiB
Python

from Controllers.Postgres.database import get_db
from Schemas import Users, Employees, BuildLivingSpace
from init_service_to_events import init_service_to_event_matches_for_super_user
from init_applications import (
init_applications_for_super_user,
init_applications_for_general_manager,
init_applications_for_build_manager,
init_applications_for_owner,
init_applications_for_tenant,
)
if __name__ == "__main__":
"""
Create Applications to serve on Next.js | Create Events to add to Service
Set Events to service | Set Service to employee
"""
with get_db() as db_session:
if super_man := Users.filter_one(
Users.email == "karatay.berkay.sup@evyos.com.tr", db=db_session
).data:
super_employee = Employees.filter_one(
Employees.people_id == super_man.person_id, db=db_session
).data
init_service_to_event_matches_for_super_user(
super_user=super_employee, db_session=db_session
)
init_applications_for_super_user(
super_user=super_employee, db_session=db_session
)
with get_db() as db_session:
print("Createing GM")
if gen_man := Users.filter_one(
Users.email == "example.general@evyos.com.tr", db=db_session
).data:
gen_man_employee = Employees.filter_one(
Employees.people_id == gen_man.person_id, db=db_session
).data
print("General Manager : ", gen_man_employee)
init_applications_for_general_manager(
super_user=gen_man_employee, db_session=db_session
)
with get_db() as db_session:
if build_man := Users.filter_one(
Users.email == "example.build.manager@gmail.com", db=db_session
).data:
build_man_employee = BuildLivingSpace.filter_one(
BuildLivingSpace.person_id == build_man.person_id, db=db_session
).data
init_applications_for_build_manager(
super_user=build_man_employee, db_session=db_session
)
with get_db() as db_session:
if own_flt := Users.filter_one(
Users.email == "example.owner@gmail.com", db=db_session
).data:
own_flt_employee = BuildLivingSpace.filter_one(
BuildLivingSpace.person_id == own_flt.person_id, db=db_session
).data
init_applications_for_owner(
super_user=own_flt_employee, db_session=db_session
)
with get_db() as db_session:
if ten_flt := Users.filter_one(
Users.email == "example.tenant@gmail.com", db=db_session
).data:
ten_flt_employee = BuildLivingSpace.filter_one(
BuildLivingSpace.person_id == ten_flt.person_id, db=db_session
).data
init_applications_for_tenant(
super_user=ten_flt_employee, db_session=db_session
)