event list token updated

This commit is contained in:
2024-12-07 16:18:11 +03:00
parent 9e955841c3
commit 6ba0e37ffd
13 changed files with 243 additions and 213 deletions

View File

@@ -106,6 +106,24 @@ class Services(CrudCollection):
)
related_responsibility: Mapped[str] = mapped_column(String, server_default="")
@classmethod
def retrieve_service_via_occupant_code(cls, occupant_code):
from databases import OccupantTypes
occupant_type = OccupantTypes.filter_by_one(
system=True,
occupant_code=occupant_code,
).data
if not occupant_type:
cls.raise_http_exception(
status_code="HTTP_404_NOT_FOUND",
error_case="RECORD_NOT_FOUND",
message=f"No occupant type found for this code : {occupant_code}",
data={
"occupant_code": occupant_code,
},
)
return cls.filter_one(cls.related_responsibility == occupant_type.occupant_code).data
__table_args__ = ({"comment": "Services Information"},)