events started
This commit is contained in:
parent
1fe88e226a
commit
93db5eff72
|
|
@ -6,32 +6,21 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b5202e0c-6ddf-4a56-a13a-e18798c4c7cf" name="Changes" comment="">
|
<list default="true" id="b5202e0c-6ddf-4a56-a13a-e18798c4c7cf" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiServices/Cluster/create_router.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiServices/Cluster/create_router.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/__init__.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/cluster.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/cluster.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/endpoints.py" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/function_handlers.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/function_handlers.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/building/build_area.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/building/build_area/build_area.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/address.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/address/address.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/building/build_parts.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/building/build_parts/build_parts.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/address/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/building/build_sites.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/building/build_sites/build_sites.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/cluster.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/address/cluster.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/building/build_types.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/building/build_types/build_types.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/function_handlers.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/address/function_handlers.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/building/living_spaces.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/building/living_spaces/living_spaces.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/address/info.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/address/info.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/company.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/company/company.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/department.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/department/department.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/cluster.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/cluster.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/duties.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/duties/duties.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/validation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/validation.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/duty.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/duty/duty.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/Engine/abstract_class.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/Engine/abstract_class.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/employee.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/employee/employee.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/base_request_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/base_request_model.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/company/staff.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/company/staff/staff.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/book_payment.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/book_payment/book_payment.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book/decision_book.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_items.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_items/decision_book_items.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_items_debits.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_items_debits/decision_book_items_debits.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_person.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/decision_book_person/decision_book_person.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/invitations.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/decision_book/invitations/invitations.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/identity/people.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/identity/people/people.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/identity/users.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/identity/users/users.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book/project_decision_book.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_items.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_items/project_decision_book_items.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_person.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_person/project_decision_book_person.py" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
@ -63,16 +52,16 @@
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "development",
|
"git-widget-placeholder": "development",
|
||||||
"last_opened_file_path": "/home/berkay/git-gitea-evyos/wag-managment-api-service-version-5/ApiLayers/ApiValidations/Queries"
|
"last_opened_file_path": "/home/berkay/git-gitea-evyos/wag-managment-api-service-version-5/Events/AllEvents/events/project_decision_book/project_decision_book_person"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/ApiLayers/ApiValidations/Queries" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_person" />
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/events/account" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_items" />
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/validations/validation" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book" />
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/template/template" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/identity/users" />
|
||||||
<recent name="$PROJECT_DIR$/ApiLayers/LanguageModels/templates" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/identity/people" />
|
||||||
</key>
|
</key>
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_person" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book_person" />
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
Events package initialization.
|
Events package initialization.
|
||||||
"""
|
"""
|
||||||
from .account.cluster import AccountCluster
|
from .account.cluster import AccountCluster
|
||||||
|
from .address.cluster import AddressCluster
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"AccountCluster",
|
"AccountCluster",
|
||||||
|
"AddressCluster"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
template related API endpoints.
|
Account related API endpoints.
|
||||||
"""
|
"""
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
@ -9,43 +9,120 @@ from Events.base_request_model import EndpointBaseRequestModel, ContextRetriever
|
||||||
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||||
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessListResponse
|
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessListResponse
|
||||||
|
|
||||||
from .api_events import account_insert_super_user_event
|
|
||||||
from .function_handlers import AccountListEventMethods
|
from .function_handlers import AccountListEventMethods
|
||||||
|
from .api_events import SuperUserAccountEvents
|
||||||
|
|
||||||
|
|
||||||
AccountRecordsEventMethods = MethodToEvent(
|
AccountRecordsListEventMethods = MethodToEvent(
|
||||||
name="AccountRecordsEventMethods",
|
name="AccountRecordsListEventMethods",
|
||||||
events={
|
events={
|
||||||
account_insert_super_user_event.key: account_insert_super_user_event,
|
SuperUserAccountEvents.SuperUserListEvent.key: SuperUserAccountEvents.SuperUserListEvent,
|
||||||
},
|
},
|
||||||
headers=[],
|
headers=[],
|
||||||
errors=[],
|
errors=[],
|
||||||
decorators_list=[TokenEventMiddleware.event_required],
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
url="/list",
|
url="/list",
|
||||||
method="POST",
|
method="POST",
|
||||||
summary="Login via domain and access key : [email] | [phone]",
|
summary="List all accounts by given previligous",
|
||||||
description="Login to the system via domain, access key : [email] | [phone]",
|
description="List all accounts by given previligous",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def account_insert_event_endpoint(
|
def account_list_event_endpoint(
|
||||||
request: Request, data: EndpointBaseRequestModel
|
request: Request, data: EndpointBaseRequestModel
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
context_retriever = ContextRetrievers(func=account_insert_event_endpoint)
|
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||||
event_2_catch = AccountRecordsEventMethods.retrieve_event(
|
event_2_catch = AccountRecordsListEventMethods.retrieve_event(
|
||||||
event_function_code=f"{account_insert_super_user_event.key}"
|
event_function_code=f"{SuperUserAccountEvents.SuperUserListEvent.key}"
|
||||||
)
|
)
|
||||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
AccountListEventMethods.context_retriever = context_retriever
|
AccountListEventMethods.context_retriever = context_retriever
|
||||||
pagination_result = event_2_catch.endpoint_callable(data=data)
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
return EndpointSuccessListResponse(
|
return EndpointSuccessListResponse(
|
||||||
code="ACCOUNTS_LIST", lang=context_retriever.token.lang
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
).as_dict(
|
).as_dict(
|
||||||
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
AccountRecordsEventMethods.endpoint_callable = (
|
AccountRecordsListEventMethods.endpoint_callable = (
|
||||||
account_insert_event_endpoint
|
account_list_event_endpoint
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AccountRecordsCreateEventMethods = MethodToEvent(
|
||||||
|
name="AccountRecordsCreateEventMethods",
|
||||||
|
events={
|
||||||
|
SuperUserAccountEvents.SuperUserCreateEvent.key: SuperUserAccountEvents.SuperUserCreateEvent,
|
||||||
|
},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/create",
|
||||||
|
method="POST",
|
||||||
|
summary="Create Account via given data and previligous",
|
||||||
|
description="Create Account via given data and previligous",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def account_create_event_endpoint(
|
||||||
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_create_event_endpoint)
|
||||||
|
event_2_catch = AccountRecordsCreateEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{SuperUserAccountEvents.SuperUserCreateEvent.key}"
|
||||||
|
)
|
||||||
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
|
AccountListEventMethods.context_retriever = context_retriever
|
||||||
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
|
return EndpointSuccessListResponse(
|
||||||
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
|
).as_dict(
|
||||||
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AccountRecordsCreateEventMethods.endpoint_callable = (
|
||||||
|
account_create_event_endpoint
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AccountRecordsUpdateEventMethods = MethodToEvent(
|
||||||
|
name="AccountRecordsUpdateEventMethods",
|
||||||
|
events={
|
||||||
|
SuperUserAccountEvents.SuperUserUpdateEvent.key: SuperUserAccountEvents.SuperUserUpdateEvent,
|
||||||
|
},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/update",
|
||||||
|
method="POST",
|
||||||
|
summary="Update Account via given data and previligous",
|
||||||
|
description="Update Account via given data and previligous",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def account_update_event_endpoint(
|
||||||
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||||
|
event_2_catch = AccountRecordsUpdateEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{SuperUserAccountEvents.SuperUserUpdateEvent.key}"
|
||||||
|
)
|
||||||
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
|
AccountListEventMethods.context_retriever = context_retriever
|
||||||
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
|
return EndpointSuccessListResponse(
|
||||||
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
|
).as_dict(
|
||||||
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AccountRecordsUpdateEventMethods.endpoint_callable = (
|
||||||
|
account_update_event_endpoint
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,13 @@
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from ApiLayers.ApiValidations.Request import ListOptions
|
|
||||||
from ApiLayers.Schemas import AccountRecords
|
|
||||||
# from ApiLayers.LanguageModels.Request import (
|
|
||||||
# LoginRequestLanguageModel,
|
|
||||||
# SelectRequestLanguageModel,
|
|
||||||
# )
|
|
||||||
from Events.Engine.abstract_class import Event
|
from Events.Engine.abstract_class import Event
|
||||||
|
|
||||||
from .models import AccountRequestValidators
|
from .models import AccountRequestValidators
|
||||||
from .function_handlers import (
|
from .function_handlers import (
|
||||||
AccountListEventMethods,
|
AccountListEventMethods,
|
||||||
|
AccountCreateEventMethods,
|
||||||
|
AccountUpdateEventMethods,
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
|
||||||
# class SelectResponseAccount(BaseModel):
|
# class SelectResponseAccount(BaseModel):
|
||||||
# """
|
# """
|
||||||
# Response model for account list.
|
# Response model for account list.
|
||||||
|
|
@ -24,8 +18,9 @@ from .function_handlers import (
|
||||||
# type_description: str
|
# type_description: str
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
# Auth Login
|
# Auth Login
|
||||||
account_insert_super_user_event = Event(
|
account_list_super_user_event = Event(
|
||||||
name="account_insert_super_user_event",
|
name="account_insert_super_user_event",
|
||||||
key="36a165fe-a2f3-437b-80ee-1ee44670fe70",
|
key="36a165fe-a2f3-437b-80ee-1ee44670fe70",
|
||||||
request_validator=AccountRequestValidators.ListAccountRecord,
|
request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
|
|
@ -37,6 +32,45 @@ account_insert_super_user_event = Event(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
account_insert_super_user_event.endpoint_callable = (
|
account_list_super_user_event.endpoint_callable = (
|
||||||
AccountListEventMethods.account_records_list
|
AccountListEventMethods.account_records_list
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
account_insert_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="3aa46155-72bc-4370-b4e7-b937b0f9b893",
|
||||||
|
request_validator=AccountRequestValidators.InsertAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="ACCOUNT_CREATED",
|
||||||
|
description="Create a new account by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
account_insert_super_user_event.endpoint_callable = (
|
||||||
|
AccountCreateEventMethods.account_records_create
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
account_update_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="3aa46155-72bc-4370-b4e7-b937b0f9b893",
|
||||||
|
request_validator=AccountRequestValidators.UpdateAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="ACCOUNT_UPDATED",
|
||||||
|
description="Update a specific account by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
account_update_super_user_event.endpoint_callable = (
|
||||||
|
AccountUpdateEventMethods.account_records_update
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SuperUserAccountEvents:
|
||||||
|
SuperUserListEvent = account_list_super_user_event
|
||||||
|
SuperUserCreateEvent = account_insert_super_user_event
|
||||||
|
SuperUserUpdateEvent = account_update_super_user_event
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,25 @@
|
||||||
from Events.Engine.abstract_class import CategoryCluster
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
|
||||||
from .account_records import AccountRecordsEventMethods
|
from .account_records import (
|
||||||
|
AccountRecordsListEventMethods,
|
||||||
|
AccountRecordsCreateEventMethods,
|
||||||
|
AccountRecordsUpdateEventMethods,
|
||||||
|
)
|
||||||
from .info import account_page_info
|
from .info import account_page_info
|
||||||
|
|
||||||
|
|
||||||
AccountCluster = CategoryCluster(
|
AccountCluster = CategoryCluster(
|
||||||
name="AccountCluster",
|
name="AccountCluster",
|
||||||
tags=["accounts"],
|
tags=["Account Records"],
|
||||||
prefix="/accounts",
|
prefix="/accounts",
|
||||||
description="Account Cluster",
|
description="Account Cluster",
|
||||||
pageinfo=account_page_info,
|
pageinfo=account_page_info,
|
||||||
endpoints={
|
endpoints={
|
||||||
"AccountRecordsEventMethods": AccountRecordsEventMethods,
|
"AccountRecordsListEventMethods": AccountRecordsListEventMethods,
|
||||||
|
"AccountRecordsCreateEventMethods": AccountRecordsCreateEventMethods,
|
||||||
|
"AccountRecordsUpdateEventMethods": AccountRecordsUpdateEventMethods,
|
||||||
},
|
},
|
||||||
include_in_schema=True,
|
include_in_schema=True,
|
||||||
sub_category=[],
|
sub_category=[],
|
||||||
|
is_client=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -291,3 +291,4 @@ class AccountUpdateEventMethods(BaseRouteModel):
|
||||||
# cls_object=AccountRecords,
|
# cls_object=AccountRecords,
|
||||||
# response_model=UpdateAccountRecord,
|
# response_model=UpdateAccountRecord,
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,351 +1,173 @@
|
||||||
"""
|
"""
|
||||||
request models.
|
Account related API endpoints.
|
||||||
"""
|
"""
|
||||||
|
from typing import Any, Dict
|
||||||
|
from fastapi import Request
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, Any, List, Optional, TypedDict, Union
|
from Events.Engine.abstract_class import MethodToEvent
|
||||||
from pydantic import BaseModel, Field, model_validator, RootModel, ConfigDict
|
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
||||||
from ApiEvents.abstract_class import MethodToEvent
|
|
||||||
from ApiEvents.base_request_model import BaseRequestModel, DictRequestModel
|
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||||
from ApiValidations.Custom.token_objects import EmployeeTokenObject, OccupantTokenObject
|
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessListResponse
|
||||||
from ApiValidations.Request.address import SearchAddress, UpdateAddress
|
|
||||||
from ApiValidations.Request.base_validations import ListOptions
|
from .function_handlers import (
|
||||||
from ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
AddressListFunctions,
|
||||||
from Schemas.identity.identity import (
|
AddressUpdateFunctions,
|
||||||
AddressPostcode,
|
AddressSearchFunctions,
|
||||||
AddressStreet,
|
AddressCreateFunctions,
|
||||||
Addresses,
|
|
||||||
RelationshipEmployee2PostCode,
|
|
||||||
)
|
)
|
||||||
from ApiValidations.Request import (
|
from .api_events import AddressSuperUserEvents
|
||||||
InsertAddress,
|
|
||||||
)
|
|
||||||
from ApiValidations.Response import (
|
AddressListEventMethods = MethodToEvent(
|
||||||
ListAddressResponse,
|
name="AddressListEventMethods",
|
||||||
|
events={
|
||||||
|
AddressSuperUserEvents.AddressListEvents.key: AddressSuperUserEvents.AddressListEvents,
|
||||||
|
},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/list",
|
||||||
|
method="POST",
|
||||||
|
summary="List all accounts by given previligous",
|
||||||
|
description="List all accounts by given previligous",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
def account_list_event_endpoint(
|
||||||
from fastapi import Request
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||||
class AddressListEventMethod(MethodToEvent):
|
event_2_catch = AddressListEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{AddressSuperUserEvents.AddressListEvents.key}"
|
||||||
event_type = "SELECT"
|
|
||||||
event_description = "List Address records"
|
|
||||||
event_category = "Address"
|
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"9c251d7d-da70-4d63-a72c-e69c26270442": "address_list_super_user",
|
|
||||||
"52afe375-dd95-4f4b-aaa2-4ec61bc6de52": "address_list_employee",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"9c251d7d-da70-4d63-a72c-e69c26270442": (
|
|
||||||
ListAddressResponse,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
"52afe375-dd95-4f4b-aaa2-4ec61bc6de52": (
|
|
||||||
ListAddressResponse,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def address_list_super_user(
|
|
||||||
cls,
|
|
||||||
list_options: ListOptions,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
db = RelationshipEmployee2PostCode.new_session()
|
|
||||||
post_code_list = RelationshipEmployee2PostCode.filter_all(
|
|
||||||
RelationshipEmployee2PostCode.company_id
|
|
||||||
== token_dict.selected_company.company_id,
|
|
||||||
db=db,
|
|
||||||
).data
|
|
||||||
post_code_id_list = [post_code.member_id for post_code in post_code_list]
|
|
||||||
if not post_code_id_list:
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=404,
|
|
||||||
detail="User has no post code registered. User can not list addresses.",
|
|
||||||
)
|
)
|
||||||
get_street_ids = [
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
street_id[0]
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
for street_id in AddressPostcode.select_only(
|
AddressListFunctions.context_retriever = context_retriever
|
||||||
AddressPostcode.id.in_(post_code_id_list),
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
select_args=[AddressPostcode.street_id],
|
return EndpointSuccessListResponse(
|
||||||
order_by=AddressPostcode.street_id.desc(),
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
db=db,
|
).as_dict(
|
||||||
).data
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
]
|
|
||||||
if not get_street_ids:
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=404,
|
|
||||||
detail="User has no street registered. User can not list addresses.",
|
|
||||||
)
|
|
||||||
Addresses.pre_query = Addresses.filter_all(
|
|
||||||
Addresses.street_id.in_(get_street_ids),
|
|
||||||
db=db,
|
|
||||||
).query
|
|
||||||
Addresses.filter_attr = list_options
|
|
||||||
records = Addresses.filter_all(db=db).data
|
|
||||||
return {}
|
|
||||||
# return AlchemyJsonResponse(
|
|
||||||
# completed=True, message="List Address records", result=records
|
|
||||||
# )
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def address_list_employee(
|
|
||||||
cls,
|
|
||||||
list_options: ListOptions,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
# Addresses.filter_attr = list_options
|
|
||||||
Addresses.pre_query = Addresses.filter_all(
|
|
||||||
Addresses.street_id.in_(get_street_ids),
|
|
||||||
)
|
|
||||||
records = Addresses.filter_all().data
|
|
||||||
return
|
|
||||||
# return AlchemyJsonResponse(
|
|
||||||
# completed=True, message="List Address records", result=records
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class AddressCreateEventMethod(MethodToEvent):
|
|
||||||
|
|
||||||
event_type = "CREATE"
|
|
||||||
event_description = ""
|
|
||||||
event_category = ""
|
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"ffdc445f-da10-4ce4-9531-d2bdb9a198ae": "create_address",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"ffdc445f-da10-4ce4-9531-d2bdb9a198ae": (
|
|
||||||
InsertAddress,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def create_address(
|
|
||||||
cls,
|
|
||||||
data: InsertAddress,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
post_code = AddressPostcode.filter_one(
|
|
||||||
AddressPostcode.uu_id == data.post_code_uu_id,
|
|
||||||
).data
|
|
||||||
if not post_code:
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=404,
|
|
||||||
detail="Post code not found. User can not create address without post code.",
|
|
||||||
)
|
|
||||||
|
|
||||||
data_dict = data.excluded_dump()
|
|
||||||
data_dict["street_id"] = post_code.street_id
|
|
||||||
data_dict["street_uu_id"] = str(post_code.street_uu_id)
|
|
||||||
del data_dict["post_code_uu_id"]
|
|
||||||
address = Addresses.find_or_create(**data_dict)
|
|
||||||
address.save()
|
|
||||||
address.update(is_confirmed=True)
|
|
||||||
address.save()
|
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True,
|
|
||||||
message="Address created successfully",
|
|
||||||
result=address.get_dict(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AddressSearchEventMethod(MethodToEvent):
|
AddressListEventMethods.endpoint_callable = (
|
||||||
"""Event methods for searching addresses.
|
account_list_event_endpoint
|
||||||
|
)
|
||||||
|
|
||||||
This class handles address search functionality including text search
|
|
||||||
and filtering.
|
|
||||||
"""
|
|
||||||
|
|
||||||
event_type = "SEARCH"
|
AddressCreateEventMethods = MethodToEvent(
|
||||||
event_description = "Search for addresses using text and filters"
|
name="AddressCreateEventMethods",
|
||||||
event_category = "Address"
|
events={
|
||||||
|
AddressSuperUserEvents.AddressCreateEvents.key: AddressSuperUserEvents.AddressCreateEvents,
|
||||||
|
},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/create",
|
||||||
|
method="POST",
|
||||||
|
summary="Create Address via given data and previligous",
|
||||||
|
description="Create Address via given data and previligous",
|
||||||
|
)
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"e0ac1269-e9a7-4806-9962-219ac224b0d0": "search_address",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"e0ac1269-e9a7-4806-9962-219ac224b0d0": (
|
|
||||||
SearchAddress,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
def account_create_event_endpoint(
|
||||||
def _build_order_clause(
|
request: Request, data: EndpointBaseRequestModel
|
||||||
cls, filter_list: Dict[str, Any], schemas: List[str], filter_table: Any
|
) -> Dict[str, Any]:
|
||||||
) -> Any:
|
context_retriever = ContextRetrievers(func=account_create_event_endpoint)
|
||||||
"""Build the ORDER BY clause for the query.
|
event_2_catch = AddressCreateEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{AddressSuperUserEvents.AddressCreateEvents.key}"
|
||||||
Args:
|
)
|
||||||
filter_list: Dictionary of filter options
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
schemas: List of available schema fields
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
filter_table: SQLAlchemy table to query
|
AddressCreateFunctions.context_retriever = context_retriever
|
||||||
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
Returns:
|
return EndpointSuccessListResponse(
|
||||||
SQLAlchemy order_by clause
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
"""
|
).as_dict(
|
||||||
# Default to ordering by UUID if field not in schema
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
if filter_list.get("order_field") not in schemas:
|
|
||||||
filter_list["order_field"] = "uu_id"
|
|
||||||
else:
|
|
||||||
# Extract table and field from order field
|
|
||||||
table_name, field_name = str(filter_list.get("order_field")).split(".")
|
|
||||||
filter_table = getattr(databases.sql_models, table_name)
|
|
||||||
filter_list["order_field"] = field_name
|
|
||||||
|
|
||||||
# Build order clause
|
|
||||||
field = getattr(filter_table, filter_list.get("order_field"))
|
|
||||||
return (
|
|
||||||
field.desc()
|
|
||||||
if str(filter_list.get("order_type"))[0] == "d"
|
|
||||||
else field.asc()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _format_record(cls, record: Any, schemas: List[str]) -> Dict[str, str]:
|
|
||||||
"""Format a database record into a dictionary.
|
|
||||||
|
|
||||||
Args:
|
AddressCreateEventMethods.endpoint_callable = (
|
||||||
record: Database record to format
|
account_create_event_endpoint
|
||||||
schemas: List of schema fields
|
)
|
||||||
|
|
||||||
Returns:
|
|
||||||
Formatted record dictionary
|
|
||||||
"""
|
|
||||||
result = {}
|
|
||||||
for index, schema in enumerate(schemas):
|
|
||||||
value = str(record[index])
|
|
||||||
# Special handling for UUID fields
|
|
||||||
if "uu_id" in value:
|
|
||||||
value = str(value)
|
|
||||||
result[schema] = value
|
|
||||||
return result
|
|
||||||
|
|
||||||
@classmethod
|
AddressUpdateEventMethods = MethodToEvent(
|
||||||
def search_address(
|
name="AddressUpdateEventMethods",
|
||||||
cls,
|
events={
|
||||||
data: SearchAddress,
|
AddressSuperUserEvents.AddressUpdateEvents.key: AddressSuperUserEvents.AddressUpdateEvents,
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
},
|
||||||
) -> Any:
|
headers=[],
|
||||||
"""Search for addresses using text search and filters.
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/update",
|
||||||
|
method="POST",
|
||||||
|
summary="Update Address via given data and previligous",
|
||||||
|
description="Update Address via given data and previligous",
|
||||||
|
)
|
||||||
|
|
||||||
Args:
|
|
||||||
data: Search parameters including text and filters
|
|
||||||
token_dict: Authentication token
|
|
||||||
|
|
||||||
Returns:
|
def account_update_event_endpoint(
|
||||||
JSON response with search results
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
Raises:
|
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||||
HTTPExceptionApi: If search fails
|
event_2_catch = AddressUpdateEventMethods.retrieve_event(
|
||||||
"""
|
event_function_code=f"{AddressSuperUserEvents.AddressUpdateEvents.key}"
|
||||||
try:
|
)
|
||||||
# Start performance measurement
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
start_time = perf_counter()
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
|
AddressUpdateFunctions.context_retriever = context_retriever
|
||||||
# Get initial query
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
search_result = AddressStreet.search_address_text(search_text=data.search)
|
return EndpointSuccessListResponse(
|
||||||
if not search_result:
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
raise HTTPExceptionApi(
|
).as_dict(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
detail="No addresses found matching search criteria",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
query = search_result.get("query")
|
|
||||||
schemas = search_result.get("schema")
|
|
||||||
|
|
||||||
# Apply filters
|
AddressUpdateEventMethods.endpoint_callable = (
|
||||||
filter_list = data.list_options.dump()
|
account_update_event_endpoint
|
||||||
filter_table = AddressStreet
|
)
|
||||||
|
|
||||||
# Build and apply order clause
|
|
||||||
order = cls._build_order_clause(filter_list, schemas, filter_table)
|
|
||||||
|
|
||||||
# Apply pagination
|
AddressSearchEventMethods = MethodToEvent(
|
||||||
page_size = int(filter_list.get("size"))
|
name="AddressSearchEventMethods",
|
||||||
offset = (int(filter_list.get("page")) - 1) * page_size
|
events={
|
||||||
|
AddressSuperUserEvents.AddressSearchEvents.key: AddressSuperUserEvents.AddressSearchEvents,
|
||||||
|
},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/search",
|
||||||
|
method="POST",
|
||||||
|
summary="Search Address via given data and previligous",
|
||||||
|
description="Search Address via given data and previligous",
|
||||||
|
)
|
||||||
|
|
||||||
# Execute query
|
|
||||||
query = (
|
def address_search_event_endpoint(
|
||||||
query.order_by(order)
|
request: Request, data: EndpointBaseRequestModel
|
||||||
.limit(page_size)
|
) -> Dict[str, Any]:
|
||||||
.offset(offset)
|
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||||
.populate_existing()
|
event_2_catch = AddressUpdateEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{AddressSuperUserEvents.AddressSearchEvents.key}"
|
||||||
)
|
)
|
||||||
records = list(query.all())
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
# Format results
|
AddressSearchFunctions.context_retriever = context_retriever
|
||||||
results = [cls._format_record(record, schemas) for record in records]
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
|
return EndpointSuccessListResponse(
|
||||||
# Log performance
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
duration = perf_counter() - start_time
|
).as_dict(
|
||||||
print(f"Address search completed in {duration:.3f}s")
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
|
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True, message="Address search results", result=results
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except HTTPExceptionApi as e:
|
AddressSearchEventMethods.endpoint_callable = (
|
||||||
# Re-raise HTTP exceptions
|
address_search_event_endpoint
|
||||||
raise e
|
)
|
||||||
except Exception as e:
|
|
||||||
# Log and wrap other errors
|
|
||||||
print(f"Address search error: {str(e)}")
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
||||||
detail="Failed to search addresses",
|
|
||||||
) from e
|
|
||||||
|
|
||||||
|
|
||||||
class AddressUpdateEventMethod(MethodToEvent):
|
|
||||||
|
|
||||||
event_type = "UPDATE"
|
|
||||||
event_description = ""
|
|
||||||
event_category = ""
|
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"1f9c3a9c-e5bd-4dcd-9b9a-3742d7e03a27": "update_address",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"1f9c3a9c-e5bd-4dcd-9b9a-3742d7e03a27": (
|
|
||||||
UpdateAddress,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def update_address(
|
|
||||||
cls,
|
|
||||||
address_uu_id: str,
|
|
||||||
data: UpdateAddress,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
if isinstance(token_dict, EmployeeTokenObject):
|
|
||||||
address = Addresses.filter_one(
|
|
||||||
Addresses.uu_id == address_uu_id,
|
|
||||||
).data
|
|
||||||
if not address:
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=404,
|
|
||||||
detail=f"Address not found. User can not update with given address uuid : {address_uu_id}",
|
|
||||||
)
|
|
||||||
|
|
||||||
data_dict = data.excluded_dump()
|
|
||||||
updated_address = address.update(**data_dict)
|
|
||||||
updated_address.save()
|
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True,
|
|
||||||
message="Address updated successfully",
|
|
||||||
result=updated_address.get_dict(),
|
|
||||||
)
|
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=403,
|
|
||||||
detail="Occupant can not update address.",
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,82 @@ from ApiLayers.LanguageModels.Request import (
|
||||||
LoginRequestLanguageModel,
|
LoginRequestLanguageModel,
|
||||||
)
|
)
|
||||||
|
|
||||||
from models import TemplateResponseModels, TemplateRequestModels
|
# from models import TemplateResponseModels, TemplateRequestModels
|
||||||
from function_handlers import TemplateFunctions
|
from .function_handlers import AddressSuperUserFunctions
|
||||||
|
|
||||||
|
|
||||||
# Auth Login
|
# Address List for super_user event
|
||||||
template_event = Event(
|
address_list_super_user_event = Event(
|
||||||
name="authentication_login_super_user_event",
|
name="account_insert_super_user_event",
|
||||||
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
key="7ce855ce-db79-4397-b0ec-f5e408ea6447",
|
||||||
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
# request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
language_models=[LoginRequestLanguageModel],
|
# response_validator=SelectResponseAccount,
|
||||||
response_validation_static="LOGIN_SUCCESS",
|
# language_models=[AccountRecords.__language_model__],
|
||||||
description="Login super user",
|
language_models=[],
|
||||||
|
statics="",
|
||||||
|
description="List address by validation list options and queries.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
address_list_super_user_event.endpoint_callable = (
|
||||||
|
AddressSuperUserFunctions.AddressListFunctions.template_example_function_list
|
||||||
|
)
|
||||||
|
|
||||||
|
# Address Create for super_user event
|
||||||
|
address_create_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="d638a6b2-cf2e-4361-99a4-021183b75ec1",
|
||||||
|
# request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="",
|
||||||
|
description="Create address by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
address_create_super_user_event.endpoint_callable = (
|
||||||
|
AddressSuperUserFunctions.AddressCreateFunctions.template_example_function_list
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Address Update for super_user event
|
||||||
|
address_update_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="d638a6b2-cf2e-4361-99a4-021183b75ec1",
|
||||||
|
# request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="",
|
||||||
|
description="Update address by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
address_update_super_user_event.endpoint_callable = (
|
||||||
|
AddressSuperUserFunctions.AddressUpdateFunctions.template_example_function_list
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Address Update for super_user event
|
||||||
|
address_search_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="d638a6b2-cf2e-4361-99a4-021183b75ec1",
|
||||||
|
# request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="",
|
||||||
|
description="Search address by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
address_search_super_user_event.endpoint_callable = (
|
||||||
|
AddressSuperUserFunctions.AddressSearchFunctions.template_example_function_list
|
||||||
|
)
|
||||||
|
|
||||||
|
class AddressSuperUserEvents:
|
||||||
|
AddressListEvents = address_list_super_user_event
|
||||||
|
AddressCreateEvents = address_create_super_user_event
|
||||||
|
AddressUpdateEvents = address_update_super_user_event
|
||||||
|
AddressSearchEvents = address_search_super_user_event
|
||||||
|
|
@ -1,14 +1,27 @@
|
||||||
from Events.Engine.abstract_class import CategoryCluster
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
from info import template_page_info
|
|
||||||
|
from .address import (
|
||||||
|
AddressListEventMethods,
|
||||||
|
AddressCreateEventMethods,
|
||||||
|
AddressUpdateEventMethods,
|
||||||
|
AddressSearchEventMethods,
|
||||||
|
)
|
||||||
|
from .info import address_page_info
|
||||||
|
|
||||||
|
|
||||||
TemplateCluster = CategoryCluster(
|
AddressCluster = CategoryCluster(
|
||||||
name="TemplateCluster",
|
name="AddressCluster",
|
||||||
tags=["template"],
|
tags=["Address"],
|
||||||
prefix="/template",
|
prefix="/address",
|
||||||
description="Template cluster",
|
description="Address Cluster",
|
||||||
pageinfo=template_page_info,
|
pageinfo=address_page_info,
|
||||||
endpoints={},
|
endpoints={
|
||||||
|
"AddressListEventMethods": AddressListEventMethods,
|
||||||
|
"AddressCreateEventMethods": AddressCreateEventMethods,
|
||||||
|
"AddressUpdateEventMethods": AddressUpdateEventMethods,
|
||||||
|
"AddressSearchEventMethods": AddressSearchEventMethods,
|
||||||
|
},
|
||||||
include_in_schema=True,
|
include_in_schema=True,
|
||||||
sub_category=[],
|
sub_category=[],
|
||||||
|
is_client=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from typing import Union, Optional
|
||||||
from ApiLayers.ApiValidations.Request import ListOptions
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
from Services.PostgresDb.Models.pagination import PaginationResult
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
from ApiLayers.Schemas import AddressNeighborhood
|
||||||
|
|
||||||
|
|
||||||
class Handlers:
|
class Handlers:
|
||||||
|
|
@ -14,38 +15,32 @@ class Handlers:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class TemplateFunctions(BaseRouteModel):
|
class AddressListFunctions(BaseRouteModel):
|
||||||
"""
|
|
||||||
Class for handling authentication functions
|
|
||||||
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
@classmethod
|
||||||
results as :
|
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
STATIC_MESSAGE & LANG retrieved from redis
|
list_options_base = ListOptionsBase(
|
||||||
{
|
table=AddressNeighborhood, list_options=data, model_query=None,
|
||||||
"completed": true,
|
)
|
||||||
"message": STATIC_MESSAGE,
|
db_session, query_options = list_options_base.init_list_options()
|
||||||
"lang": LANG,
|
if cls.context_retriever.token.is_occupant:
|
||||||
"pagination": {
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
"size": 10,
|
AddressNeighborhood.neighborhood_code.icontains("10"),
|
||||||
"page": 2,
|
db=db_session,
|
||||||
"allCount": 28366,
|
).query
|
||||||
"totalCount": 18,
|
elif cls.context_retriever.token.is_employee:
|
||||||
"totalPages": 2,
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
"pageCount": 8,
|
AddressNeighborhood.neighborhood_code.icontains("9"),
|
||||||
"orderField": ["type_code", "neighborhood_name"],
|
db=db_session,
|
||||||
"orderType": ["asc", "desc"]
|
).query
|
||||||
},
|
records = AddressNeighborhood.filter_all(*query_options.convert(), db=db_session)
|
||||||
"data": [
|
return list_options_base.paginated_result(
|
||||||
{
|
records=records, response_model=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
||||||
"created_at": "2025-01-12 09:39:48 +00:00",
|
)
|
||||||
"active": true,
|
|
||||||
"expiry_starts": "2025-01-12 09:39:48 +00:00",
|
|
||||||
"locality_uu_id": "771fd152-aca1-4d75-a42e-9b29ea7112b5",
|
class AddressCreateFunctions(BaseRouteModel):
|
||||||
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
|
|
@ -68,3 +63,66 @@ class TemplateFunctions(BaseRouteModel):
|
||||||
return list_options_base.paginated_result(
|
return list_options_base.paginated_result(
|
||||||
records=records, response_model=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
records=records, response_model=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AddressSearchFunctions(BaseRouteModel):
|
||||||
|
"""Event methods for searching addresses.
|
||||||
|
|
||||||
|
This class handles address search functionality including text search
|
||||||
|
and filtering.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
|
from ApiLayers.Schemas import AddressNeighborhood
|
||||||
|
list_options_base = ListOptionsBase(
|
||||||
|
table=AddressNeighborhood, list_options=data, model_query=None,
|
||||||
|
)
|
||||||
|
db_session, query_options = list_options_base.init_list_options()
|
||||||
|
if cls.context_retriever.token.is_occupant:
|
||||||
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
|
AddressNeighborhood.neighborhood_code.icontains("10"),
|
||||||
|
db=db_session,
|
||||||
|
).query
|
||||||
|
elif cls.context_retriever.token.is_employee:
|
||||||
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
|
AddressNeighborhood.neighborhood_code.icontains("9"),
|
||||||
|
db=db_session,
|
||||||
|
).query
|
||||||
|
records = AddressNeighborhood.filter_all(*query_options.convert(), db=db_session)
|
||||||
|
return list_options_base.paginated_result(
|
||||||
|
records=records, response_model=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AddressUpdateFunctions(BaseRouteModel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
|
from ApiLayers.Schemas import AddressNeighborhood
|
||||||
|
list_options_base = ListOptionsBase(
|
||||||
|
table=AddressNeighborhood, list_options=data, model_query=None,
|
||||||
|
)
|
||||||
|
db_session, query_options = list_options_base.init_list_options()
|
||||||
|
if cls.context_retriever.token.is_occupant:
|
||||||
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
|
AddressNeighborhood.neighborhood_code.icontains("10"),
|
||||||
|
db=db_session,
|
||||||
|
).query
|
||||||
|
elif cls.context_retriever.token.is_employee:
|
||||||
|
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||||
|
AddressNeighborhood.neighborhood_code.icontains("9"),
|
||||||
|
db=db_session,
|
||||||
|
).query
|
||||||
|
records = AddressNeighborhood.filter_all(*query_options.convert(), db=db_session)
|
||||||
|
return list_options_base.paginated_result(
|
||||||
|
records=records, response_model=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AddressSuperUserFunctions:
|
||||||
|
AddressListFunctions = AddressListFunctions
|
||||||
|
AddressCreateFunctions = AddressCreateFunctions
|
||||||
|
AddressSearchFunctions = AddressSearchFunctions
|
||||||
|
AddressUpdateFunctions = AddressUpdateFunctions
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from Events.Engine.abstract_class import PageInfo
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
template_page_info = PageInfo(
|
address_page_info = PageInfo(
|
||||||
name="template",
|
name="template",
|
||||||
title={"en": "template"},
|
title={"en": "template"},
|
||||||
description={"en": "template"},
|
description={"en": "template"},
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from .models import ValidationsPydantic
|
||||||
from .function_handlers import RetrieveValidation
|
from .function_handlers import RetrieveValidation
|
||||||
|
|
||||||
|
|
||||||
# Auth Login
|
# Validation Event
|
||||||
validation_event = Event(
|
validation_event = Event(
|
||||||
name="validation_event",
|
name="validation_event",
|
||||||
key="02b5a596-14ba-4361-90d7-c6755727c63f",
|
key="02b5a596-14ba-4361-90d7-c6755727c63f",
|
||||||
|
|
@ -23,3 +23,21 @@ def get_validation_by_event_function_code(request: Request, data: Any):
|
||||||
|
|
||||||
|
|
||||||
validation_event.endpoint_callable = get_validation_by_event_function_code
|
validation_event.endpoint_callable = get_validation_by_event_function_code
|
||||||
|
|
||||||
|
|
||||||
|
# Menu Event
|
||||||
|
menu_event = Event(
|
||||||
|
name="menu_event",
|
||||||
|
key="a1613ca0-4843-498b-bfff-07ecea6777b2",
|
||||||
|
request_validator=ValidationsPydantic,
|
||||||
|
language_models=[],
|
||||||
|
statics=None,
|
||||||
|
description="Get Left Menu of the user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_menu_by_event_function_code(request: Request, data: Any):
|
||||||
|
return RetrieveValidation.retrieve_validation(data=data)
|
||||||
|
|
||||||
|
|
||||||
|
menu_event.endpoint_callable = get_menu_by_event_function_code
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
from Events.Engine.abstract_class import CategoryCluster
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
|
||||||
from .validation import ValidationEventMethods
|
from .validation import (
|
||||||
|
ValidationEventMethods,
|
||||||
|
MenuEventMethods,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
ValidationsCluster = CategoryCluster(
|
ValidationsCluster = CategoryCluster(
|
||||||
|
|
@ -10,6 +13,7 @@ ValidationsCluster = CategoryCluster(
|
||||||
description="Validations cluster",
|
description="Validations cluster",
|
||||||
endpoints={
|
endpoints={
|
||||||
"ValidationEventMethods": ValidationEventMethods,
|
"ValidationEventMethods": ValidationEventMethods,
|
||||||
|
"MenuEventMethods": MenuEventMethods,
|
||||||
},
|
},
|
||||||
include_in_schema=True,
|
include_in_schema=True,
|
||||||
sub_category=[],
|
sub_category=[],
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
template related API endpoints.
|
Validation related API endpoints.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
@ -9,7 +9,7 @@ from Events.Engine.abstract_class import MethodToEvent
|
||||||
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
||||||
from ApiLayers.Middleware.auth_middleware import MiddlewareModule
|
from ApiLayers.Middleware.auth_middleware import MiddlewareModule
|
||||||
|
|
||||||
from .api_events import validation_event
|
from .api_events import validation_event, menu_event
|
||||||
from .function_handlers import RetrieveValidation
|
from .function_handlers import RetrieveValidation
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,19 +26,41 @@ ValidationEventMethods = MethodToEvent(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def authentication_login_with_domain_and_creds_endpoint(
|
def validations_endpoint(
|
||||||
request: Request, data: EndpointBaseRequestModel
|
request: Request, data: EndpointBaseRequestModel
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
function = ValidationEventMethods.retrieve_event(
|
function = ValidationEventMethods.retrieve_event(
|
||||||
event_function_code=f"{validation_event.key}"
|
event_function_code=f"{validation_event.key}"
|
||||||
)
|
)
|
||||||
data = function.REQUEST_VALIDATOR(**data.data)
|
data = function.REQUEST_VALIDATOR(**data.data)
|
||||||
RetrieveValidation.context_retriever = ContextRetrievers(
|
RetrieveValidation.context_retriever = ContextRetrievers(func=validations_endpoint)
|
||||||
func=authentication_login_with_domain_and_creds_endpoint
|
|
||||||
)
|
|
||||||
return function.endpoint_callable(request=request, data=data)
|
return function.endpoint_callable(request=request, data=data)
|
||||||
|
|
||||||
|
|
||||||
ValidationEventMethods.endpoint_callable = (
|
ValidationEventMethods.endpoint_callable = validations_endpoint
|
||||||
authentication_login_with_domain_and_creds_endpoint
|
|
||||||
|
|
||||||
|
MenuEventMethods = MethodToEvent(
|
||||||
|
name="MenuEventMethods",
|
||||||
|
events={menu_event.key: menu_event},
|
||||||
|
headers=[],
|
||||||
|
errors=[],
|
||||||
|
url="/menu",
|
||||||
|
method="POST",
|
||||||
|
decorators_list=[MiddlewareModule.auth_required],
|
||||||
|
summary="Get Left Menu of the user",
|
||||||
|
description="Get Left Menu of the user",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def menu_endpoint(
|
||||||
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
function = ValidationEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{menu_event.key}"
|
||||||
|
)
|
||||||
|
data = function.REQUEST_VALIDATOR(**data.data)
|
||||||
|
RetrieveValidation.context_retriever = ContextRetrievers(func=validations_endpoint)
|
||||||
|
return function.endpoint_callable(request=request, data=data)
|
||||||
|
|
||||||
|
MenuEventMethods.endpoint_callable = menu_endpoint
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,10 @@ class Event:
|
||||||
return static_response.first
|
return static_response.first
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def static_key(self):
|
||||||
|
return self.STATICS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
return f"This is an event of {self.name}. Description: {self.DESCRIPTION}"
|
return f"This is an event of {self.name}. Description: {self.DESCRIPTION}"
|
||||||
|
|
@ -186,6 +190,7 @@ class CategoryCluster:
|
||||||
ENDPOINTS: dict[str, MethodToEvent] # {"MethodToEvent": MethodToEvent, ...}
|
ENDPOINTS: dict[str, MethodToEvent] # {"MethodToEvent": MethodToEvent, ...}
|
||||||
SUBCATEGORY: Optional[List["CategoryCluster"]] # [CategoryCluster, ...]
|
SUBCATEGORY: Optional[List["CategoryCluster"]] # [CategoryCluster, ...]
|
||||||
INCLUDE_IN_SCHEMA: Optional[bool] = True
|
INCLUDE_IN_SCHEMA: Optional[bool] = True
|
||||||
|
IS_CLIENT: Optional[bool] = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
@ -197,6 +202,7 @@ class CategoryCluster:
|
||||||
sub_category: list,
|
sub_category: list,
|
||||||
pageinfo: Optional[PageInfo] = None,
|
pageinfo: Optional[PageInfo] = None,
|
||||||
include_in_schema: Optional[bool] = True,
|
include_in_schema: Optional[bool] = True,
|
||||||
|
is_client: Optional[bool] = False,
|
||||||
):
|
):
|
||||||
self.NAME = name
|
self.NAME = name
|
||||||
self.TAGS = tags
|
self.TAGS = tags
|
||||||
|
|
@ -206,6 +212,11 @@ class CategoryCluster:
|
||||||
self.ENDPOINTS = endpoints or {}
|
self.ENDPOINTS = endpoints or {}
|
||||||
self.SUBCATEGORY = sub_category or []
|
self.SUBCATEGORY = sub_category or []
|
||||||
self.INCLUDE_IN_SCHEMA = include_in_schema
|
self.INCLUDE_IN_SCHEMA = include_in_schema
|
||||||
|
self.IS_CLIENT = is_client
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_client(self):
|
||||||
|
return self.IS_CLIENT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class ContextRetrievers:
|
||||||
key_: str = ""
|
key_: str = ""
|
||||||
RESPONSE_VALIDATOR = None
|
RESPONSE_VALIDATOR = None
|
||||||
|
|
||||||
def __init__(self, func):
|
def __init__(self, func, statics: Optional[str] = None):
|
||||||
self.func = func
|
self.func = func
|
||||||
if hasattr(self.func, "auth_context"):
|
if hasattr(self.func, "auth_context"):
|
||||||
self.is_auth = True
|
self.is_auth = True
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue