updated update base models
This commit is contained in:
@@ -204,13 +204,10 @@ class BuildUpdateEventMethods(MethodToEvent):
|
||||
data: UpdateBuild,
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
Build.pre_query = Build.select_action(
|
||||
employee_id=token_dict.selected_company.employee_id
|
||||
)
|
||||
if Build.filter_all(
|
||||
Build.person_id == token_dict.person_id,
|
||||
).data:
|
||||
Build.pre_query = None
|
||||
if isinstance(token_dict, OccupantTokenObject):
|
||||
Build.pre_query = Build.select_action(
|
||||
employee_id=token_dict.selected_company.employee_id
|
||||
)
|
||||
updated_build = Build.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
)
|
||||
@@ -219,10 +216,30 @@ class BuildUpdateEventMethods(MethodToEvent):
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Build record",
|
||||
"data": updated_build,
|
||||
"data": updated_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
elif isinstance(token_dict, EmployeeTokenObject):
|
||||
find_one_build = Build.filter_one(
|
||||
Build.uu_id == build_uu_id,
|
||||
).data
|
||||
access_authorized_build = Build.select_action(
|
||||
employee_id=token_dict.selected_company.employee_id,
|
||||
filter_expr=[Build.id == find_one_build.id],
|
||||
)
|
||||
if access_authorized_build.count:
|
||||
updated_build = Build.update_action(
|
||||
data=data, token=token_dict, build_uu_id=build_uu_id
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Build record",
|
||||
"data": updated_build.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail=f"This user can not modify {build_uu_id} - building.",
|
||||
|
||||
Reference in New Issue
Block a user