alchemy functions updated

This commit is contained in:
2024-11-10 13:36:52 +03:00
parent eb947ecb3d
commit be100a6615
18 changed files with 83 additions and 61 deletions

View File

@@ -496,7 +496,7 @@ class Addresses(CrudCollection):
post_code_list = RelationshipEmployee2PostCode.filter_all(
RelationshipEmployee2PostCode.employee_id
== token_dict.selected_company.employee_id,
RelationshipEmployee2PostCode.active == True,
*RelationshipEmployee2PostCode.valid_record_args(RelationshipEmployee2PostCode)
).data
post_code_id_list = [post_code.member_id for post_code in post_code_list]
if not post_code_id_list:
@@ -504,10 +504,12 @@ class Addresses(CrudCollection):
status_code=404,
detail="User has no post code registered. User can not list addresses.",
)
cls.pre_query = cls.filter_active(cls.post_code_id.in_(post_code_id_list)).query
cls.pre_query = cls.filter_all(
cls.post_code_id.in_(post_code_id_list), cls.valid_record_args(cls)
).query
filter_cls = cls.filter_all(*filter_expr)
cls.pre_query = None
return filter_cls
return filter_cls.data
# buildings: Mapped["Build"] = relationship(
# "Build", back_populates="addresses", foreign_keys="Build.address_id"