updated postgres and mongo updated
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
from Controllers.Postgres.database import get_db
|
||||
from Schemas import (
|
||||
Users,
|
||||
Employees,
|
||||
)
|
||||
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
|
||||
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__":
|
||||
@@ -26,3 +29,49 @@ if __name__ == "__main__":
|
||||
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
|
||||
)
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
from Schemas import Applications, Application2Employee, Employees
|
||||
from Schemas import (
|
||||
Applications,
|
||||
Application2Employee,
|
||||
Application2Occupant,
|
||||
Employees,
|
||||
BuildLivingSpace,
|
||||
)
|
||||
|
||||
|
||||
def init_applications_for_super_user(super_user: Employees, db_session=None) -> None:
|
||||
@@ -109,3 +115,111 @@ def init_applications_for_super_user(super_user: Employees, db_session=None) ->
|
||||
)
|
||||
if application_employee_created.meta_data.created:
|
||||
application_employee_created.save(db=db_session)
|
||||
|
||||
|
||||
def init_applications_for_general_manager(
|
||||
super_user: Employees, db_session=None
|
||||
) -> None:
|
||||
list_of_created_apps = [
|
||||
dict(
|
||||
name="Dashboard1",
|
||||
application_code="app000001",
|
||||
site_url="/dashboard",
|
||||
application_type="info",
|
||||
description="Dashboard Page",
|
||||
),
|
||||
dict(
|
||||
name="ManagementAccounting",
|
||||
application_code="app000008",
|
||||
site_url="/management/accounting",
|
||||
application_type="Dash",
|
||||
description="Individual Page for management accounting",
|
||||
),
|
||||
]
|
||||
for list_of_created_app in list_of_created_apps:
|
||||
created_page = Applications.find_or_create(
|
||||
**list_of_created_app,
|
||||
db=db_session,
|
||||
)
|
||||
print("Application : ", created_page)
|
||||
if created_page.meta_data.created:
|
||||
created_page.save(db=db_session)
|
||||
|
||||
application_employee_created = Application2Employee.find_or_create(
|
||||
employee_id=super_user.id,
|
||||
employee_uu_id=str(super_user.uu_id),
|
||||
site_url=created_page.site_url,
|
||||
application_code=created_page.application_code,
|
||||
application_id=created_page.id,
|
||||
application_uu_id=str(created_page.uu_id),
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
)
|
||||
print("Application Employee : ", application_employee_created)
|
||||
if application_employee_created.meta_data.created:
|
||||
application_employee_created.save(db=db_session)
|
||||
|
||||
|
||||
def init_applications_for_build_manager(
|
||||
super_user: BuildLivingSpace, db_session=None
|
||||
) -> None:
|
||||
list_of_created_apps = []
|
||||
|
||||
|
||||
def init_applications_for_owner(super_user: BuildLivingSpace, db_session=None) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def init_applications_for_tenant(super_user: BuildLivingSpace, db_session=None) -> None:
|
||||
list_of_created_apps = [
|
||||
dict(
|
||||
name="Dashboard1",
|
||||
application_code="app000001",
|
||||
site_url="/dashboard",
|
||||
application_type="info",
|
||||
description="Dashboard Page",
|
||||
),
|
||||
dict(
|
||||
name="TenantSendMessageToBuildManager",
|
||||
application_code="app000014",
|
||||
site_url="/tenant/messageToBM",
|
||||
application_type="Dash",
|
||||
description="Individual Page for tenant send message to build manager",
|
||||
),
|
||||
dict(
|
||||
name="TenantSendMessageToOwner",
|
||||
application_code="app000018",
|
||||
site_url="/tenant/messageToOwner",
|
||||
application_type="Dash",
|
||||
description="Individual Page for tenant send message to owner",
|
||||
),
|
||||
dict(
|
||||
name="TenantAccountView",
|
||||
application_code="app000019",
|
||||
site_url="/tenant/accounting",
|
||||
application_type="Dash",
|
||||
description="Individual Page for tenant account view",
|
||||
),
|
||||
]
|
||||
|
||||
for list_of_created_app in list_of_created_apps:
|
||||
created_page = Applications.find_or_create(
|
||||
**list_of_created_app,
|
||||
db=db_session,
|
||||
is_confirmed=True,
|
||||
)
|
||||
if created_page.meta_data.created:
|
||||
created_page.save(db=db_session)
|
||||
|
||||
application_occupant_created = Application2Occupant.find_or_create(
|
||||
build_living_space_id=super_user.id,
|
||||
build_living_space_uu_id=str(super_user.uu_id),
|
||||
site_url=created_page.site_url,
|
||||
application_code=created_page.application_code,
|
||||
application_id=created_page.id,
|
||||
application_uu_id=str(created_page.uu_id),
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
)
|
||||
if application_occupant_created.meta_data.created:
|
||||
application_occupant_created.save(db=db_session)
|
||||
|
||||
Reference in New Issue
Block a user