test application updated@build living space

This commit is contained in:
2024-11-15 19:23:08 +03:00
parent d2cc195ccf
commit 7e1b26f3c4
44 changed files with 261 additions and 321 deletions

View File

@@ -19,6 +19,7 @@ from sqlalchemy import (
Numeric,
)
from api_library.date_time_actions.date_functions import system_arrow
from databases.sql_models.core_mixin import CrudCollection
from databases.extensions.selector_classes import SelectActionWithEmployee
@@ -240,7 +241,6 @@ class Build(CrudCollection, SelectActionWithEmployee):
if data.address_uu_id:
official_address = Addresses.filter_one(
Addresses.uu_id==data.address_uu_id,
*Addresses.valid_record_args(Addresses)
).data
data_dict["address_id"] = official_address.id
data_dict["build_no"] = str(official_address.build_number)
@@ -305,7 +305,6 @@ class Build(CrudCollection, SelectActionWithEmployee):
def livable_part_count(self):
livable_parts = BuildParts.filter_all(
BuildParts.build_id == self.id, BuildParts.human_livable == True,
*BuildParts.valid_record_args(BuildParts)
)
if not livable_parts.data:
raise HTTPException(
@@ -422,7 +421,6 @@ class BuildParts(CrudCollection):
if build_types := BuildTypes.filter_one(
BuildTypes.uu_id == data.build_part_type_uu_id,
*BuildTypes.valid_record_args(BuildTypes)
).data:
part_direction = ApiEnumDropdown.get_by_uuid(
uuid=str(data.part_direction_uu_id)
@@ -554,15 +552,24 @@ class BuildLivingSpace(CrudCollection):
from api_events.events.events.events_bind_services import (
ServiceBindOccupantEventMethods,
)
if data.get('expiry_starts'):
data['expiry_starts'] = str(system_arrow.get(data['expiry_starts']))
if data.get('expiry_ends'):
data['expiry_ends'] = str(system_arrow.get(data['expiry_ends']))
created_living_space = BuildLivingSpace.find_or_create(**data)
occupant_type = OccupantTypes.find_one(
occupant_type = OccupantTypes.filter_by_one(
system=True,
uu_id=created_living_space.occupant_type_uu_id
)
related_service = Services.find_one(
active=True,
).data
related_service = Services.filter_by_one(
related_responsibility=occupant_type.occupant_code,
)
**Services.valid_record_dict
).data
created_living_space.save()
created_living_space.is_confirmed = True
created_living_space.save()
if not related_service:
raise HTTPException(
status_code=status.HTTP_418_IM_A_TEAPOT,
@@ -584,7 +591,6 @@ class BuildLivingSpace(CrudCollection):
or_(
cls.owner_person_id == customer_id,
cls.life_person_id == customer_id,
*cls.valid_record_args(cls)
),
cls.start_date < formatted_date - timedelta(days=add_days),
cls.stop_date > formatted_date + timedelta(days=add_days),