updated postgres and mongo updated
This commit is contained in:
@@ -24,10 +24,12 @@ from Schemas import (
|
||||
Duties,
|
||||
Departments,
|
||||
Event2Employee,
|
||||
Application2Occupant,
|
||||
Event2Occupant,
|
||||
Application2Employee,
|
||||
RelationshipEmployee2Build,
|
||||
)
|
||||
from Modules.Token.password_module import PasswordModule
|
||||
from Schemas.building.build import RelationshipEmployee2Build
|
||||
from Schemas.event.event import Event2Occupant, Application2Employee
|
||||
from Controllers.Redis.database import RedisActions
|
||||
from Controllers.Mongo.database import mongo_handler
|
||||
|
||||
@@ -151,7 +153,11 @@ class LoginHandler:
|
||||
|
||||
@classmethod
|
||||
def do_employee_login(
|
||||
cls, request: Any, data: Any, extra_dict: Optional[Dict[str, Any]] = None
|
||||
cls,
|
||||
request: Any,
|
||||
data: Any,
|
||||
db_session,
|
||||
extra_dict: Optional[Dict[str, Any]] = None,
|
||||
):
|
||||
"""
|
||||
Handle employee login.
|
||||
@@ -161,109 +167,113 @@ class LoginHandler:
|
||||
timezone = extra_dict.get("tz", None) or "GMT+3"
|
||||
|
||||
user_handler = UserHandlers()
|
||||
with Users.new_session() as db_session:
|
||||
found_user = user_handler.check_user_exists(
|
||||
access_key=data.access_key, db_session=db_session
|
||||
)
|
||||
found_user = user_handler.check_user_exists(
|
||||
access_key=data.access_key, db_session=db_session
|
||||
)
|
||||
|
||||
if not user_handler.check_password_valid(
|
||||
domain=domain or "",
|
||||
id_=str(found_user.uu_id),
|
||||
password=data.password,
|
||||
password_hashed=found_user.hash_password,
|
||||
):
|
||||
raise ValueError("EYS_0005")
|
||||
if not user_handler.check_password_valid(
|
||||
domain=domain or "",
|
||||
id_=str(found_user.uu_id),
|
||||
password=data.password,
|
||||
password_hashed=found_user.hash_password,
|
||||
):
|
||||
raise ValueError("EYS_0005")
|
||||
|
||||
list_employee = Employees.filter_all(
|
||||
Employees.people_id == found_user.person_id, db=db_session
|
||||
list_employee = Employees.filter_all(
|
||||
Employees.people_id == found_user.person_id, db=db_session
|
||||
).data
|
||||
|
||||
companies_uu_id_list: list = []
|
||||
companies_id_list: list = []
|
||||
companies_list: list = []
|
||||
duty_uu_id_list: list = []
|
||||
duty_id_list: list = []
|
||||
|
||||
for employee in list_employee:
|
||||
duty_found = None
|
||||
staff = Staff.filter_one(Staff.id == employee.staff_id, db=db_session).data
|
||||
if duties := Duties.filter_one(
|
||||
Duties.id == staff.duties_id, db=db_session
|
||||
).data:
|
||||
if duty_found := Duty.filter_by_one(
|
||||
id=duties.duties_id, db=db_session
|
||||
).data:
|
||||
duty_uu_id_list.append(str(duty_found.uu_id))
|
||||
duty_id_list.append(duty_found.id)
|
||||
duty_found = duty_found.duty_name
|
||||
|
||||
department = Departments.filter_one(
|
||||
Departments.id == duties.department_id, db=db_session
|
||||
).data
|
||||
|
||||
companies_uu_id_list: list = []
|
||||
companies_id_list: list = []
|
||||
companies_list: list = []
|
||||
duty_uu_id_list: list = []
|
||||
duty_id_list: list = []
|
||||
|
||||
for employee in list_employee:
|
||||
staff = Staff.filter_one(
|
||||
Staff.id == employee.staff_id, db=db_session
|
||||
if company := Companies.filter_one(
|
||||
Companies.id == department.company_id, db=db_session
|
||||
).data:
|
||||
companies_uu_id_list.append(str(company.uu_id))
|
||||
companies_id_list.append(company.id)
|
||||
company_address = Addresses.filter_by_one(
|
||||
id=company.official_address_id, db=db_session
|
||||
).data
|
||||
if duties := Duties.filter_one(
|
||||
Duties.id == staff.duties_id, db=db_session
|
||||
).data:
|
||||
if duty_found := Duty.filter_by_one(
|
||||
id=duties.duties_id, db=db_session
|
||||
).data:
|
||||
duty_uu_id_list.append(str(duty_found.uu_id))
|
||||
duty_id_list.append(duty_found.id)
|
||||
companies_list.append(
|
||||
{
|
||||
"uu_id": str(company.uu_id),
|
||||
"public_name": company.public_name,
|
||||
"company_type": company.company_type,
|
||||
"company_address": company_address,
|
||||
"duty": duty_found,
|
||||
}
|
||||
)
|
||||
person = People.filter_one(
|
||||
People.id == found_user.person_id, db=db_session
|
||||
).data
|
||||
model_value = EmployeeTokenObject(
|
||||
user_type=UserType.employee.value,
|
||||
user_uu_id=str(found_user.uu_id),
|
||||
user_id=found_user.id,
|
||||
person_id=found_user.person_id,
|
||||
person_uu_id=str(person.uu_id),
|
||||
request=dict(request.headers),
|
||||
companies_uu_id_list=companies_uu_id_list,
|
||||
companies_id_list=companies_id_list,
|
||||
duty_uu_id_list=duty_uu_id_list,
|
||||
duty_id_list=duty_id_list,
|
||||
).model_dump()
|
||||
|
||||
department = Departments.filter_one(
|
||||
Departments.id == duties.department_id, db=db_session
|
||||
).data
|
||||
|
||||
if company := Companies.filter_one(
|
||||
Companies.id == department.company_id, db=db_session
|
||||
).data:
|
||||
companies_uu_id_list.append(str(company.uu_id))
|
||||
companies_id_list.append(company.id)
|
||||
company_address = Addresses.filter_by_one(
|
||||
id=company.official_address_id, db=db_session
|
||||
).data
|
||||
companies_list.append(
|
||||
{
|
||||
"uu_id": str(company.uu_id),
|
||||
"public_name": company.public_name,
|
||||
"company_type": company.company_type,
|
||||
"company_address": company_address,
|
||||
}
|
||||
)
|
||||
person = People.filter_one(
|
||||
People.id == found_user.person_id, db=db_session
|
||||
).data
|
||||
model_value = EmployeeTokenObject(
|
||||
user_type=UserType.employee.value,
|
||||
user_uu_id=str(found_user.uu_id),
|
||||
user_id=found_user.id,
|
||||
person_id=found_user.person_id,
|
||||
person_uu_id=str(person.uu_id),
|
||||
request=dict(request.headers),
|
||||
companies_uu_id_list=companies_uu_id_list,
|
||||
companies_id_list=companies_id_list,
|
||||
duty_uu_id_list=duty_uu_id_list,
|
||||
duty_id_list=duty_id_list,
|
||||
).model_dump()
|
||||
|
||||
set_to_redis_dict = dict(
|
||||
user=found_user,
|
||||
token=model_value,
|
||||
header_info=dict(language=language, domain=domain, timezone=timezone),
|
||||
)
|
||||
redis_handler = RedisHandlers()
|
||||
if access_token := redis_handler.set_object_to_redis(**set_to_redis_dict):
|
||||
return {
|
||||
"access_token": access_token,
|
||||
"user_type": UserType.employee.name,
|
||||
"user": found_user.get_dict(
|
||||
exclude_list=[
|
||||
Users.hash_password,
|
||||
Users.cryp_uu_id,
|
||||
Users.password_token,
|
||||
Users.created_credentials_token,
|
||||
Users.updated_credentials_token,
|
||||
Users.confirmed_credentials_token,
|
||||
Users.is_confirmed,
|
||||
Users.is_notification_send,
|
||||
Users.is_email_send,
|
||||
Users.remember_me,
|
||||
]
|
||||
),
|
||||
"selection_list": companies_list,
|
||||
}
|
||||
set_to_redis_dict = dict(
|
||||
user=found_user,
|
||||
token=model_value,
|
||||
header_info=dict(language=language, domain=domain, timezone=timezone),
|
||||
)
|
||||
redis_handler = RedisHandlers()
|
||||
if access_token := redis_handler.set_object_to_redis(**set_to_redis_dict):
|
||||
return {
|
||||
"access_token": access_token,
|
||||
"user_type": UserType.employee.name,
|
||||
"user": found_user.get_dict(
|
||||
exclude_list=[
|
||||
Users.hash_password,
|
||||
Users.cryp_uu_id,
|
||||
Users.password_token,
|
||||
Users.created_credentials_token,
|
||||
Users.updated_credentials_token,
|
||||
Users.confirmed_credentials_token,
|
||||
Users.is_confirmed,
|
||||
Users.is_notification_send,
|
||||
Users.is_email_send,
|
||||
Users.remember_me,
|
||||
]
|
||||
),
|
||||
"selection_list": companies_list,
|
||||
}
|
||||
raise ValueError("Something went wrong")
|
||||
|
||||
@classmethod
|
||||
def do_employee_occupant(
|
||||
cls, request: Any, data: Any, extra_dict: Optional[Dict[str, Any]] = None
|
||||
def do_occupant_login(
|
||||
cls,
|
||||
request: Any,
|
||||
data: Any,
|
||||
db_session,
|
||||
extra_dict: Optional[Dict[str, Any]] = None,
|
||||
):
|
||||
"""
|
||||
Handle occupant login.
|
||||
@@ -273,63 +283,58 @@ class LoginHandler:
|
||||
timezone = extra_dict.get("tz", None) or "GMT+3"
|
||||
|
||||
user_handler = UserHandlers()
|
||||
with Users.new_session() as db_session:
|
||||
found_user = user_handler.check_user_exists(
|
||||
access_key=data.access_key, db_session=db_session
|
||||
)
|
||||
if not user_handler.check_password_valid(
|
||||
domain=data.domain,
|
||||
id_=str(found_user.uu_id),
|
||||
password=data.password,
|
||||
password_hashed=found_user.hash_password,
|
||||
):
|
||||
raise ValueError("EYS_0005")
|
||||
found_user = user_handler.check_user_exists(
|
||||
access_key=data.access_key, db_session=db_session
|
||||
)
|
||||
if not user_handler.check_password_valid(
|
||||
domain=domain,
|
||||
id_=str(found_user.uu_id),
|
||||
password=data.password,
|
||||
password_hashed=found_user.hash_password,
|
||||
):
|
||||
raise ValueError("EYS_0005")
|
||||
|
||||
occupants_selection_dict: Dict[str, Any] = {}
|
||||
living_spaces: list[BuildLivingSpace] = BuildLivingSpace.filter_all(
|
||||
BuildLivingSpace.person_id == found_user.person_id, db=db_session
|
||||
occupants_selection_dict: Dict[str, Any] = {}
|
||||
living_spaces: list[BuildLivingSpace] = BuildLivingSpace.filter_all(
|
||||
BuildLivingSpace.person_id == found_user.person_id, db=db_session
|
||||
).data
|
||||
|
||||
if not living_spaces:
|
||||
raise ValueError("EYS_0006")
|
||||
for living_space in living_spaces:
|
||||
build_part = BuildParts.filter_one(
|
||||
BuildParts.id == living_space.build_parts_id,
|
||||
db=db_session,
|
||||
).data
|
||||
if not build_part:
|
||||
raise ValueError("EYS_0007")
|
||||
|
||||
if not living_spaces:
|
||||
raise ValueError("EYS_0006")
|
||||
for living_space in living_spaces:
|
||||
build_parts_selection = BuildParts.filter_all(
|
||||
BuildParts.id == living_space.build_parts_id,
|
||||
db=db_session,
|
||||
).data
|
||||
if not build_parts_selection:
|
||||
raise ValueError("EYS_0007")
|
||||
build = build_part.buildings
|
||||
occupant_type = OccupantTypes.filter_by_one(
|
||||
id=living_space.occupant_type_id,
|
||||
db=db_session,
|
||||
system=True,
|
||||
).data
|
||||
occupant_data = {
|
||||
"build_living_space_uu_id": str(living_space.uu_id),
|
||||
"part_uu_id": str(build_part.uu_id),
|
||||
"part_name": build_part.part_name(db=db_session),
|
||||
"part_level": build_part.part_level,
|
||||
"occupant_uu_id": str(occupant_type.uu_id),
|
||||
"description": occupant_type.occupant_description,
|
||||
"code": occupant_type.occupant_code,
|
||||
}
|
||||
|
||||
build_part = build_parts_selection[0]
|
||||
|
||||
build = build_part.buildings
|
||||
occupant_type = OccupantTypes.filter_by_one(
|
||||
id=living_space.occupant_type,
|
||||
db=db_session,
|
||||
system=True,
|
||||
).data
|
||||
|
||||
occupant_data = {
|
||||
"part_uu_id": str(build_part.uu_id),
|
||||
"part_name": build_part.part_name,
|
||||
"part_level": build_part.part_level,
|
||||
"uu_id": str(occupant_type.uu_id),
|
||||
"description": occupant_type.occupant_description,
|
||||
"code": occupant_type.occupant_code,
|
||||
build_key = str(build.uu_id)
|
||||
if build_key not in occupants_selection_dict:
|
||||
occupants_selection_dict[build_key] = {
|
||||
"build_uu_id": build_key,
|
||||
"build_name": build.build_name,
|
||||
"build_no": build.build_no,
|
||||
"occupants": [occupant_data],
|
||||
}
|
||||
|
||||
build_key = str(build.uu_id)
|
||||
if build_key not in occupants_selection_dict:
|
||||
occupants_selection_dict[build_key] = {
|
||||
"build_uu_id": build_key,
|
||||
"build_name": build.build_name,
|
||||
"build_no": build.build_no,
|
||||
"occupants": [occupant_data],
|
||||
}
|
||||
else:
|
||||
occupants_selection_dict[build_key]["occupants"].append(
|
||||
occupant_data
|
||||
)
|
||||
else:
|
||||
occupants_selection_dict[build_key]["occupants"].append(occupant_data)
|
||||
|
||||
person = found_user.person
|
||||
model_value = OccupantTokenObject(
|
||||
@@ -363,7 +368,6 @@ class LoginHandler:
|
||||
request: FastAPI request object
|
||||
data: Request body containing login credentials
|
||||
{
|
||||
"domain": "evyos.com.tr",
|
||||
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
||||
"password": "string",
|
||||
"remember_me": false
|
||||
@@ -374,29 +378,31 @@ class LoginHandler:
|
||||
language = request.headers.get("language", "tr")
|
||||
domain = request.headers.get("domain", None)
|
||||
timezone = request.headers.get("tz", None) or "GMT+3"
|
||||
|
||||
if cls.is_employee(data.access_key):
|
||||
return cls.do_employee_login(
|
||||
request=request,
|
||||
data=data,
|
||||
extra_dict=dict(
|
||||
language=language,
|
||||
domain=domain,
|
||||
timezone=timezone,
|
||||
),
|
||||
)
|
||||
elif cls.is_occupant(data.access_key):
|
||||
return cls.do_employee_login(
|
||||
request=request,
|
||||
data=data,
|
||||
extra_dict=dict(
|
||||
language=language,
|
||||
domain=domain,
|
||||
timezone=timezone,
|
||||
),
|
||||
)
|
||||
else:
|
||||
raise ValueError("Invalid email format")
|
||||
with Users.new_session() as db_session:
|
||||
if cls.is_employee(data.access_key):
|
||||
return cls.do_employee_login(
|
||||
request=request,
|
||||
data=data,
|
||||
extra_dict=dict(
|
||||
language=language,
|
||||
domain=domain,
|
||||
timezone=timezone,
|
||||
),
|
||||
db_session=db_session,
|
||||
)
|
||||
elif cls.is_occupant(data.access_key):
|
||||
return cls.do_occupant_login(
|
||||
request=request,
|
||||
data=data,
|
||||
extra_dict=dict(
|
||||
language=language,
|
||||
domain=domain,
|
||||
timezone=timezone,
|
||||
),
|
||||
db_session=db_session,
|
||||
)
|
||||
else:
|
||||
raise ValueError("Invalid email format")
|
||||
|
||||
@classmethod
|
||||
def raise_error_if_request_has_no_token(cls, request: Any) -> None:
|
||||
@@ -525,23 +531,23 @@ class LoginHandler:
|
||||
BuildParts.id == selected_build_living_space.build_parts_id,
|
||||
db=db,
|
||||
).data
|
||||
build = BuildParts.filter_one(
|
||||
BuildParts.id == build_part.build_id,
|
||||
db=db,
|
||||
).data
|
||||
responsible_employee = Employees.filter_one(
|
||||
Employees.id == build_part.responsible_employee_id,
|
||||
db=db,
|
||||
).data
|
||||
related_company = RelationshipEmployee2Build.filter_one(
|
||||
RelationshipEmployee2Build.member_id == build.id,
|
||||
db=db,
|
||||
).data
|
||||
build = build_part.buildings
|
||||
reachable_app_codes = Application2Occupant.get_application_codes(
|
||||
build_living_space_id=selected_build_living_space.id, db=db
|
||||
)
|
||||
# responsible_employee = Employees.filter_one(
|
||||
# Employees.id == build_part.responsible_employee_id,
|
||||
# db=db,
|
||||
# ).data
|
||||
# related_company = RelationshipEmployee2Build.filter_one(
|
||||
# RelationshipEmployee2Build.member_id == build.id,
|
||||
# db=db,
|
||||
# ).data
|
||||
# Get company
|
||||
company_related = Companies.filter_one(
|
||||
Companies.id == related_company.company_id,
|
||||
db=db,
|
||||
).data
|
||||
# company_related = Companies.filter_one(
|
||||
# Companies.id == related_company.company_id,
|
||||
# db=db,
|
||||
# ).data
|
||||
|
||||
# Create occupant token
|
||||
occupant_token = OccupantToken(
|
||||
@@ -554,18 +560,19 @@ class LoginHandler:
|
||||
build_uuid=build.uu_id.__str__(),
|
||||
build_part_id=build_part.id,
|
||||
build_part_uuid=build_part.uu_id.__str__(),
|
||||
responsible_employee_id=responsible_employee.id,
|
||||
responsible_employee_uuid=responsible_employee.uu_id.__str__(),
|
||||
responsible_company_id=company_related.id,
|
||||
responsible_company_uuid=company_related.uu_id.__str__(),
|
||||
# responsible_employee_id=responsible_employee.id,
|
||||
# responsible_employee_uuid=responsible_employee.uu_id.__str__(),
|
||||
# responsible_company_id=company_related.id,
|
||||
# responsible_company_uuid=company_related.uu_id.__str__(),
|
||||
reachable_event_codes=reachable_event_codes,
|
||||
reachable_app_codes=reachable_app_codes,
|
||||
)
|
||||
redis_handler = RedisHandlers()
|
||||
redis_handler.update_token_at_redis(
|
||||
token=access_token, add_payload=occupant_token
|
||||
)
|
||||
return {
|
||||
"selected_uu_id": data.company_uu_id,
|
||||
"selected_uu_id": occupant_token.living_space_uu_id,
|
||||
}
|
||||
|
||||
@classmethod # Requires auth context
|
||||
@@ -715,15 +722,23 @@ class PageHandlers:
|
||||
"""
|
||||
if result := RedisHandlers.get_object_from_redis(access_token=access_token):
|
||||
if result.is_employee:
|
||||
if application := result.selected_company.reachable_app_codes.get(
|
||||
page_url, None
|
||||
if (
|
||||
result.selected_company
|
||||
and result.selected_company.reachable_app_codes
|
||||
):
|
||||
return application
|
||||
if application := result.selected_company.reachable_app_codes.get(
|
||||
page_url, None
|
||||
):
|
||||
return application
|
||||
elif result.is_occupant:
|
||||
if application := result.selected_company.reachable_app_codes.get(
|
||||
page_url, None
|
||||
if (
|
||||
result.selected_occupant
|
||||
and result.selected_occupant.reachable_app_codes
|
||||
):
|
||||
return application
|
||||
if application := result.selected_occupant.reachable_app_codes.get(
|
||||
page_url, None
|
||||
):
|
||||
return application
|
||||
raise ValueError("EYS_0013")
|
||||
|
||||
@classmethod
|
||||
@@ -737,9 +752,17 @@ class PageHandlers:
|
||||
"""
|
||||
if result := RedisHandlers.get_object_from_redis(access_token=access_token):
|
||||
if result.is_employee:
|
||||
return result.selected_company.reachable_app_codes.keys()
|
||||
if (
|
||||
result.selected_company
|
||||
and result.selected_company.reachable_app_codes
|
||||
):
|
||||
return result.selected_company.reachable_app_codes.keys()
|
||||
elif result.is_occupant:
|
||||
return result.selected_company.reachable_app_codes.keys()
|
||||
if (
|
||||
result.selected_occupant
|
||||
and result.selected_occupant.reachable_app_codes
|
||||
):
|
||||
return result.selected_occupant.reachable_app_codes.keys()
|
||||
raise ValueError("EYS_0013")
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -6,16 +6,19 @@ from init_alembic import generate_alembic
|
||||
from init_occupant_types import create_occupant_types_defaults
|
||||
from init_services import create_modules_and_services_and_actions
|
||||
from init_address import create_one_address
|
||||
from init_occ_defaults import create_occupant_defaults
|
||||
|
||||
set_alembic = True
|
||||
set_alembic = False
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
with get_db() as db_session:
|
||||
if set_alembic:
|
||||
generate_alembic(session=db_session)
|
||||
|
||||
create_one_address(db_session=db_session)
|
||||
init_api_enums_build_types(db_session=db_session)
|
||||
create_application_defaults(db_session=db_session)
|
||||
create_occupant_types_defaults(db_session=db_session)
|
||||
create_modules_and_services_and_actions(db_session=db_session)
|
||||
create_one_address(db_session=db_session)
|
||||
create_occupant_defaults(db_session=db_session)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from Schemas import (
|
||||
Addresses,
|
||||
AddressCity,
|
||||
AddressStreet,
|
||||
AddressLocality,
|
||||
@@ -78,6 +79,22 @@ def create_one_address(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
address_list.append(street)
|
||||
address = Addresses.find_or_create(
|
||||
street_id=street.id,
|
||||
street_uu_id=str(street.uu_id),
|
||||
build_number="Ex1",
|
||||
door_number="1",
|
||||
floor_number="1",
|
||||
comment_address="Example Address",
|
||||
letter_address="Example Address",
|
||||
short_letter_address="Example Address",
|
||||
latitude=0,
|
||||
longitude=0,
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
)
|
||||
address_list.append(address)
|
||||
|
||||
for address_single in address_list:
|
||||
address_single.save(db=db_session)
|
||||
return
|
||||
if address_single.meta_data.created:
|
||||
address_single.save(db=db_session)
|
||||
|
||||
@@ -50,6 +50,16 @@ def create_application_defaults(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(execution)
|
||||
gen_man = Departments.find_or_create(
|
||||
department_name="General Manager Example",
|
||||
department_code="GM001",
|
||||
company_id=company_id,
|
||||
company_uu_id=str(company_uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_man)
|
||||
|
||||
it_dept = Departments.find_or_create(
|
||||
department_name="IT Department",
|
||||
department_code="ITD001",
|
||||
@@ -59,6 +69,16 @@ def create_application_defaults(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(it_dept)
|
||||
|
||||
gen_duty = Duty.find_or_create(
|
||||
duty_name="General Manager",
|
||||
duty_code="GM0001",
|
||||
duty_description="General Manager",
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_duty)
|
||||
|
||||
bm_duty = Duty.find_or_create(
|
||||
duty_name="Business Manager",
|
||||
duty_code="BM0001",
|
||||
@@ -91,6 +111,19 @@ def create_application_defaults(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(occu_duty)
|
||||
|
||||
duties_gen_man = Duties.find_or_create(
|
||||
company_id=company_id,
|
||||
company_uu_id=str(company_uu_id),
|
||||
duties_id=gen_duty.id,
|
||||
duties_uu_id=str(gen_duty.uu_id),
|
||||
department_id=gen_man.id,
|
||||
department_uu_id=str(gen_man.uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(duties_gen_man)
|
||||
|
||||
duties_created_bm = Duties.find_or_create(
|
||||
company_id=company_id,
|
||||
company_uu_id=str(company_uu_id),
|
||||
@@ -292,6 +325,24 @@ def create_application_defaults(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(sup_manager)
|
||||
gen_manager_people = People.find_or_create(
|
||||
**{
|
||||
"person_tag": "BM-System",
|
||||
"firstname": "Example General Manager",
|
||||
"surname": "Example",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312314",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231233",
|
||||
},
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_manager_people)
|
||||
application_manager_staff = Staff.find_or_create(
|
||||
staff_description="Application Manager",
|
||||
staff_name="Application Manager Employee",
|
||||
@@ -318,6 +369,32 @@ def create_application_defaults(db_session):
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(super_user_staff)
|
||||
gen_man_staff = Staff.find_or_create(
|
||||
staff_description="General Manager",
|
||||
staff_name="General Manager Employee",
|
||||
staff_code="GME",
|
||||
duties_id=duties_gen_man.id,
|
||||
duties_uu_id=str(gen_duty.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_man_staff)
|
||||
gen_man_employee = Employees.find_or_create(
|
||||
staff_id=gen_man_staff.id,
|
||||
staff_uu_id=str(gen_man_staff.uu_id),
|
||||
people_id=gen_manager_people.id,
|
||||
people_uu_id=str(gen_manager_people.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_man_employee)
|
||||
|
||||
app_manager_employee = Employees.find_or_create(
|
||||
staff_id=application_manager_staff.id,
|
||||
staff_uu_id=str(application_manager_staff.uu_id),
|
||||
@@ -344,6 +421,38 @@ def create_application_defaults(db_session):
|
||||
)
|
||||
created_list.append(super_user_employee)
|
||||
|
||||
gen_manager_user = Users.find_or_create(
|
||||
person_id=gen_manager_people.id,
|
||||
person_uu_id=str(gen_manager_people.uu_id),
|
||||
user_tag=gen_manager_people.person_tag,
|
||||
email="example.general@evyos.com.tr",
|
||||
phone_number="+901111111111",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(gen_manager_user)
|
||||
gen_manager_user.password_expiry_begins = str(arrow.now())
|
||||
gen_manager_user.password_token = PasswordModule.generate_refresher_token()
|
||||
|
||||
main_domain, collection_name = (
|
||||
"evyos.com.tr",
|
||||
f"{str(company_management.uu_id)}*Domain",
|
||||
)
|
||||
with mongo_handler.collection(collection_name) as mongo_engine:
|
||||
mongo_engine.insert_one(
|
||||
document={
|
||||
"user_uu_id": str(gen_manager_user.uu_id),
|
||||
"other_domains_list": [main_domain],
|
||||
"main_domain": main_domain,
|
||||
"modified_at": arrow.now().timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
app_manager_user = Users.find_or_create(
|
||||
person_id=app_manager.id,
|
||||
person_uu_id=str(app_manager.uu_id),
|
||||
@@ -362,10 +471,6 @@ def create_application_defaults(db_session):
|
||||
app_manager_user.password_expiry_begins = str(arrow.now())
|
||||
app_manager_user.password_token = PasswordModule.generate_refresher_token()
|
||||
|
||||
main_domain, collection_name = (
|
||||
"evyos.com.tr",
|
||||
f"{str(company_management.uu_id)}*Domain",
|
||||
)
|
||||
with mongo_handler.collection(collection_name) as mongo_engine:
|
||||
mongo_engine.insert_one(
|
||||
document={
|
||||
|
||||
314
ApiServices/InitialService/init_occ_defaults.py
Normal file
314
ApiServices/InitialService/init_occ_defaults.py
Normal file
@@ -0,0 +1,314 @@
|
||||
import arrow
|
||||
|
||||
from Modules.Token.password_module import PasswordModule
|
||||
from Controllers.Mongo.database import mongo_handler
|
||||
|
||||
|
||||
def create_occupant_defaults(db_session):
|
||||
from Schemas import (
|
||||
Addresses,
|
||||
BuildLivingSpace,
|
||||
Users,
|
||||
People,
|
||||
Build,
|
||||
BuildParts,
|
||||
BuildTypes,
|
||||
ApiEnumDropdown,
|
||||
Companies,
|
||||
OccupantTypes,
|
||||
)
|
||||
|
||||
created_list = []
|
||||
|
||||
company_management = Companies.filter_one(
|
||||
Companies.formal_name == "Evyos LTD",
|
||||
db=db_session,
|
||||
).data
|
||||
|
||||
if not company_management:
|
||||
raise Exception("Company not found")
|
||||
|
||||
company_id, company_uu_id = company_management.id, str(company_management.uu_id)
|
||||
active_row = dict(
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
build_type = BuildTypes.filter_one(
|
||||
BuildTypes.type_code == "APT",
|
||||
db=db_session,
|
||||
).data
|
||||
address = Addresses.filter_one(
|
||||
Addresses.letter_address == "Example Address",
|
||||
db=db_session,
|
||||
).data
|
||||
|
||||
created_build = Build.find_or_create(
|
||||
build_name="Build Example",
|
||||
build_code="B001",
|
||||
build_no="B001",
|
||||
build_date="01.07.1980",
|
||||
address_id=address.id,
|
||||
address_uu_id=str(address.uu_id),
|
||||
company_id=company_id,
|
||||
build_types_id=build_type.id,
|
||||
build_types_uu_id=str(build_type.uu_id),
|
||||
company_uu_id=str(company_uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_build)
|
||||
|
||||
build_type_created = BuildTypes.filter_one(
|
||||
BuildTypes.type_code == "APT",
|
||||
db=db_session,
|
||||
).data
|
||||
build_type_flat = BuildTypes.filter_one(
|
||||
BuildTypes.type_code == "DAIRE",
|
||||
db=db_session,
|
||||
).data
|
||||
|
||||
enum_dropdown = ApiEnumDropdown.filter_one(
|
||||
ApiEnumDropdown.key == "NE",
|
||||
ApiEnumDropdown.enum_class == "Directions",
|
||||
db=db_session,
|
||||
).data
|
||||
|
||||
occupant_type_prs = OccupantTypes.filter_one(
|
||||
OccupantTypes.occupant_code == "MT-PRS",
|
||||
db=db_session,
|
||||
).data
|
||||
occupant_type_owner = OccupantTypes.filter_one(
|
||||
OccupantTypes.occupant_code == "FL-OWN",
|
||||
db=db_session,
|
||||
).data
|
||||
occupant_type_tenant = OccupantTypes.filter_one(
|
||||
OccupantTypes.occupant_code == "FL-TEN",
|
||||
db=db_session,
|
||||
).data
|
||||
|
||||
created_managment_room = BuildParts.find_or_create(
|
||||
address_gov_code="123123123123",
|
||||
build_id=created_build.id,
|
||||
build_uu_id=str(created_build.uu_id),
|
||||
part_code="MR001",
|
||||
part_net_size=100,
|
||||
part_no=0,
|
||||
part_level=0,
|
||||
part_type_id=build_type_created.id,
|
||||
part_type_uu_id=str(build_type_created.uu_id),
|
||||
part_direction_id=enum_dropdown.id,
|
||||
part_direction_uu_id=str(enum_dropdown.uu_id),
|
||||
human_livable=True,
|
||||
due_part_key="Example",
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_managment_room)
|
||||
created_flat = BuildParts.find_or_create(
|
||||
address_gov_code="123123123124",
|
||||
build_id=created_build.id,
|
||||
build_uu_id=str(created_build.uu_id),
|
||||
part_code="MF001",
|
||||
part_net_size=100,
|
||||
part_no=1,
|
||||
part_level=1,
|
||||
part_type_id=build_type_flat.id,
|
||||
part_type_uu_id=str(build_type_flat.uu_id),
|
||||
part_direction_id=enum_dropdown.id,
|
||||
part_direction_uu_id=str(enum_dropdown.uu_id),
|
||||
human_livable=True,
|
||||
due_part_key="Example",
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_flat)
|
||||
|
||||
build_manager_people = People.find_or_create(
|
||||
**{
|
||||
"person_tag": "Build Manager Example",
|
||||
"firstname": "Example Build Manager",
|
||||
"surname": "Example",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312315",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231234",
|
||||
},
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(build_manager_people)
|
||||
owner_people = People.find_or_create(
|
||||
**{
|
||||
"person_tag": "Owner Example",
|
||||
"firstname": "Example Owner",
|
||||
"surname": "Example",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312316",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231234",
|
||||
},
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(owner_people)
|
||||
tenant_people = People.find_or_create(
|
||||
**{
|
||||
"person_tag": "Tenant Example",
|
||||
"firstname": "Example Tenant",
|
||||
"surname": "Example",
|
||||
"sex_code": "M",
|
||||
"middle_name": "",
|
||||
"father_name": "Father",
|
||||
"mother_name": "Mother",
|
||||
"country_code": "TR",
|
||||
"national_identity_id": "12312312317",
|
||||
"birth_place": "Ankara",
|
||||
"birth_date": "01.07.1990",
|
||||
"tax_no": "1231231234",
|
||||
},
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(tenant_people)
|
||||
main_domain, collection_name = (
|
||||
"evyos.com.tr",
|
||||
f"{str(company_management.uu_id)}*Domain",
|
||||
)
|
||||
|
||||
user_build_manager = Users.find_or_create(
|
||||
person_id=build_manager_people.id,
|
||||
person_uu_id=str(build_manager_people.uu_id),
|
||||
user_tag=build_manager_people.person_tag,
|
||||
email="example.build.manager@gmail.com",
|
||||
phone_number="+901111111111",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(user_build_manager)
|
||||
user_build_manager.password_expiry_begins = str(arrow.now())
|
||||
user_build_manager.password_token = PasswordModule.generate_refresher_token()
|
||||
|
||||
user_owner = Users.find_or_create(
|
||||
person_id=owner_people.id,
|
||||
person_uu_id=str(owner_people.uu_id),
|
||||
user_tag=owner_people.person_tag,
|
||||
email="example.owner@gmail.com",
|
||||
phone_number="+901111111111",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(user_owner)
|
||||
user_owner.password_expiry_begins = str(arrow.now())
|
||||
user_owner.password_token = PasswordModule.generate_refresher_token()
|
||||
|
||||
user_tenant = Users.find_or_create(
|
||||
person_id=tenant_people.id,
|
||||
person_uu_id=str(tenant_people.uu_id),
|
||||
user_tag=tenant_people.person_tag,
|
||||
email="example.tenant@gmail.com",
|
||||
phone_number="+901111111111",
|
||||
avatar="https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg",
|
||||
related_company=str(company_management.uu_id),
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(user_tenant)
|
||||
user_tenant.password_expiry_begins = str(arrow.now())
|
||||
user_tenant.password_token = PasswordModule.generate_refresher_token()
|
||||
|
||||
with mongo_handler.collection(collection_name) as mongo_engine:
|
||||
mongo_engine.insert_one(
|
||||
document={
|
||||
"user_uu_id": str(user_build_manager.uu_id),
|
||||
"other_domains_list": [main_domain],
|
||||
"main_domain": main_domain,
|
||||
"modified_at": arrow.now().timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
with mongo_handler.collection(collection_name) as mongo_engine:
|
||||
mongo_engine.insert_one(
|
||||
document={
|
||||
"user_uu_id": str(user_owner.uu_id),
|
||||
"other_domains_list": [main_domain],
|
||||
"main_domain": main_domain,
|
||||
"modified_at": arrow.now().timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
with mongo_handler.collection(collection_name) as mongo_engine:
|
||||
mongo_engine.insert_one(
|
||||
document={
|
||||
"user_uu_id": str(user_tenant.uu_id),
|
||||
"other_domains_list": [main_domain],
|
||||
"main_domain": main_domain,
|
||||
"modified_at": arrow.now().timestamp(),
|
||||
}
|
||||
)
|
||||
|
||||
created_build_living_space_prs = BuildLivingSpace.find_or_create(
|
||||
build_id=created_build.id,
|
||||
build_uu_id=str(created_build.uu_id),
|
||||
build_parts_id=created_managment_room.id,
|
||||
build_parts_uu_id=str(created_managment_room.uu_id),
|
||||
person_id=build_manager_people.id,
|
||||
person_uu_id=str(build_manager_people.uu_id),
|
||||
occupant_type_id=occupant_type_prs.id,
|
||||
occupant_type_uu_id=str(occupant_type_prs.uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_build_living_space_prs)
|
||||
|
||||
created_build_living_space_owner = BuildLivingSpace.find_or_create(
|
||||
build_id=created_build.id,
|
||||
build_uu_id=str(created_build.uu_id),
|
||||
build_parts_id=created_flat.id,
|
||||
build_parts_uu_id=str(created_flat.uu_id),
|
||||
person_id=owner_people.id,
|
||||
person_uu_id=str(owner_people.uu_id),
|
||||
occupant_type_id=occupant_type_owner.id,
|
||||
occupant_type_uu_id=str(occupant_type_owner.uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_build_living_space_owner)
|
||||
|
||||
created_build_living_space_tenant = BuildLivingSpace.find_or_create(
|
||||
build_id=created_build.id,
|
||||
build_uu_id=str(created_build.uu_id),
|
||||
build_parts_id=created_flat.id,
|
||||
build_parts_uu_id=str(created_flat.uu_id),
|
||||
person_id=tenant_people.id,
|
||||
person_uu_id=str(tenant_people.uu_id),
|
||||
occupant_type_id=occupant_type_tenant.id,
|
||||
occupant_type_uu_id=str(occupant_type_tenant.uu_id),
|
||||
**active_row,
|
||||
db=db_session,
|
||||
)
|
||||
created_list.append(created_build_living_space_tenant)
|
||||
|
||||
db_session.commit()
|
||||
print("Occupant Defaults Create is now completed")
|
||||
Reference in New Issue
Block a user