alcehmy and event functions updated
This commit is contained in:
@@ -16,7 +16,6 @@ from sqlalchemy import (
|
||||
TIMESTAMP,
|
||||
Text,
|
||||
Numeric,
|
||||
Identity,
|
||||
)
|
||||
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
@@ -331,25 +330,27 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
data_dict["build_types_id"] = build_type.id
|
||||
del data_dict["build_types_uu_id"]
|
||||
build_created = cls.find_or_create(**data_dict)
|
||||
if not build_created.is_found:
|
||||
cls.__many__table__.find_or_create(
|
||||
company_id=token.selected_company.company_id,
|
||||
employee_id=token.selected_company.employee_id,
|
||||
member_id=build_created.id,
|
||||
is_confirmed=True,
|
||||
)
|
||||
cls.__many__table__.find_or_create(
|
||||
company_id=token.selected_company.company_id,
|
||||
employee_id=token.selected_company.employee_id,
|
||||
member_id=build_created.id,
|
||||
is_confirmed=True,
|
||||
)
|
||||
return build_created
|
||||
|
||||
@classmethod
|
||||
def update_action(cls, data: UpdateBuild, build_uu_id: str, token):
|
||||
from databases import Addresses
|
||||
|
||||
data_dict = data.excluded_dump()
|
||||
if data.official_address_uu_id:
|
||||
official_address = Addresses.find_one(uu_id=data.address_uu_id)
|
||||
data_dict["address_id"] = official_address.id
|
||||
official_address = Addresses.filter_one(
|
||||
Addresses.uu_id==data.address_uu_id
|
||||
).data
|
||||
data_dict["address_id"] = official_address.id if official_address else None
|
||||
del data_dict["address_uu_id"]
|
||||
if build_to_update := cls.find_one(uu_id=build_uu_id, person_id=token.id):
|
||||
if build_to_update := cls.filter_one(
|
||||
cls.uu_id==build_uu_id, cls.person_id==token.id
|
||||
).data:
|
||||
return build_to_update.update(**data_dict)
|
||||
|
||||
@property
|
||||
@@ -489,7 +490,9 @@ class BuildParts(CrudCollection):
|
||||
"Check with your supervisor.",
|
||||
)
|
||||
|
||||
if build_types := BuildTypes.find_one(uu_id=data.build_part_type_uu_id):
|
||||
if build_types := BuildTypes.filter_one(
|
||||
BuildTypes.uu_id==data.build_part_type_uu_id
|
||||
).data:
|
||||
part_direction = ApiEnumDropdown.get_by_uuid(
|
||||
uuid=str(data.part_direction_uu_id)
|
||||
)
|
||||
@@ -516,13 +519,13 @@ class BuildParts(CrudCollection):
|
||||
|
||||
if not data_dict["part_gross_size"]:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
detail="Part Gross Size can not be empty.",
|
||||
)
|
||||
|
||||
if not data_dict["part_net_size"]:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_418_IM_A_TEAPOT,
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
detail="Part Net Size can not be empty.",
|
||||
)
|
||||
pt = int(data_dict["part_net_size"])
|
||||
|
||||
Reference in New Issue
Block a user