events imports are checked
This commit is contained in:
@@ -587,27 +587,26 @@ class BuildLivingSpace(CrudCollection):
|
||||
data: dict,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from database_sql_models import Services, OccupantTypes
|
||||
from events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
from databases import Services, OccupantTypes
|
||||
from api_events.events.events.events_bind_services import ServiceBindOccupantEventMethods
|
||||
|
||||
created_living_space = BuildLivingSpace.find_or_create(**data)
|
||||
if not created_living_space.is_found:
|
||||
occupant_type = OccupantTypes.find_one(
|
||||
uu_id=created_living_space.occupant_type_uu_id
|
||||
)
|
||||
related_service = Services.find_one(
|
||||
active=True,
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
)
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
detail="Service is not found in database. Re-enter service record then try again.",
|
||||
)
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
service_id=related_service.id,
|
||||
build_living_space_id=created_living_space.id,
|
||||
occupant_type = OccupantTypes.find_one(
|
||||
uu_id=created_living_space.occupant_type_uu_id
|
||||
)
|
||||
related_service = Services.find_one(
|
||||
active=True,
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
)
|
||||
if not related_service:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
detail="Service is not found in database. Re-enter service record then try again.",
|
||||
)
|
||||
ServiceBindOccupantEventMethods.bind_services_occupant_system(
|
||||
service_id=related_service.id,
|
||||
build_living_space_id=created_living_space.id,
|
||||
)
|
||||
return created_living_space
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user