Compare commits
11 Commits
af82f74eb6
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cd12a5c3f | |||
| e16c7fc177 | |||
| 2c5b6956c8 | |||
| 45ed5b86fd | |||
| 378d016d0c | |||
| b67090087a | |||
| f0613e96e8 | |||
| df82daea86 | |||
| 7404da6930 | |||
| 93db5eff72 | |||
| 1fe88e226a |
23
.idea/workspace.xml
generated
23
.idea/workspace.xml
generated
@@ -5,10 +5,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<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$/Ztest/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Ztest/Dockerfile" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/Middleware/token_event_middleware.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/Middleware/token_event_middleware.py" afterDir="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/template/template/function_handlers.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/template/template/function_handlers.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" />
|
||||||
@@ -40,19 +37,23 @@
|
|||||||
"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-latest"
|
||||||
}
|
}
|
||||||
}]]></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$/ApiLayers/AllConfigs" />
|
<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_items" />
|
||||||
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/project_decision_book/project_decision_book" />
|
||||||
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/building/living_spaces" />
|
||||||
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/building/build_types" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="Python.how_to">
|
<component name="RunManager" selected="Python.how_to">
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class RedisAuthKeys:
|
|||||||
AUTH: str = "AUTH"
|
AUTH: str = "AUTH"
|
||||||
OCCUPANT: str = "OCCUPANT"
|
OCCUPANT: str = "OCCUPANT"
|
||||||
EMPLOYEE: str = "EMPLOYEE"
|
EMPLOYEE: str = "EMPLOYEE"
|
||||||
|
CACHE: str = "CACHE"
|
||||||
|
|
||||||
|
|
||||||
class RedisCategoryKeys:
|
class RedisCategoryKeys:
|
||||||
@@ -50,6 +51,53 @@ class RedisCategoryKeys:
|
|||||||
MENU_MAPPER: str = "MENU_MAPPER"
|
MENU_MAPPER: str = "MENU_MAPPER"
|
||||||
|
|
||||||
|
|
||||||
|
class RedisCategoryPageInfoKeys:
|
||||||
|
"""
|
||||||
|
### /create?site=BuildingCluster, #/update?site=BuildingCluster, #/dashboard?site=BuildingCluster
|
||||||
|
PAGE_URL: /dashboard?site=BuildingCluster
|
||||||
|
PAGE_NAME: BuildingCluster
|
||||||
|
PAGE_INFO: {LANGUAGE_MODELS: "", ICON: "", URL: ""}
|
||||||
|
PAGE_MENU_INDEX: 1 # {build_living_space: "uuid4", LAYER: 1, MENU_INDEX: 1}
|
||||||
|
|
||||||
|
PAGE_MENU_COMPONENT: {..., lang: {"tr"}: {...}, lang: {"en"}: {...}}
|
||||||
|
PAGE_LANGUAGE: {{"tr"}: {...},{"en"}: {...}}
|
||||||
|
"""
|
||||||
|
|
||||||
|
PAGE_URL: str = "PAGE_URL"
|
||||||
|
PAGE_NAME: str = "PAGE_NAME"
|
||||||
|
PAGE_INFO: str = "PAGE_INFO"
|
||||||
|
PAGE_COMPONENT: str = "PAGE_COMPONENT"
|
||||||
|
PAGE_MENU_INDEX: str = "PAGE_MENU_INDEX"
|
||||||
|
PAGE_MENU_COMPONENT: str = "PAGE_MENU_COMPONENT"
|
||||||
|
PAGE_LANGUAGE: str = "PAGE_LANGUAGE"
|
||||||
|
|
||||||
|
|
||||||
|
class RedisCategoryPageInfoKeysAction:
|
||||||
|
"""
|
||||||
|
PAGE_MAPPER: {PAGE_URL: /dashboard?site=BuildingCluster, PAGE_NAME: BuildingCluster, PAGE_INFO: {LANGUAGE_MODELS: "", ICON: "", URL: ""}}
|
||||||
|
value : {RedisCategoryPageInfoKeys.PAGE_INFO}
|
||||||
|
MENU_MAPPER: {PAGE_MENU_INDEX: 1, PAGE_MENU_COMPONENT: {..., lang: {"tr"}: {...}, lang: {"en"}: {...}}}
|
||||||
|
value : {RedisCategoryPageInfoKeys.PAGE_INFO}
|
||||||
|
"""
|
||||||
|
|
||||||
|
page_index: str = (
|
||||||
|
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||||
|
)
|
||||||
|
|
||||||
|
page_mapper_key: str = (
|
||||||
|
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||||
|
)
|
||||||
|
page_mapper_key: str = (
|
||||||
|
f"{page_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_LANGUAGE}"
|
||||||
|
)
|
||||||
|
menu_mapper_key: str = (
|
||||||
|
f"{RedisCategoryPageInfoKeys.PAGE_URL}:{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}"
|
||||||
|
)
|
||||||
|
menu_mapper_key: str = (
|
||||||
|
f"{menu_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_MENU_COMPONENT}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RedisValidationKeysAction:
|
class RedisValidationKeysAction:
|
||||||
# LANGUAGE_MODELS:DYNAMIC:VALIDATIONS:
|
# LANGUAGE_MODELS:DYNAMIC:VALIDATIONS:
|
||||||
dynamic_validation_key: str = (
|
dynamic_validation_key: str = (
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ class CreateRouterFromCluster:
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.prefix = kwargs.get("prefix")
|
self.prefix = kwargs.get("prefix")
|
||||||
self.tags = kwargs.get("tags")
|
self.tags = kwargs.get("tags")
|
||||||
self.router = APIRouter(prefix=self.prefix, tags=self.tags)
|
self.include_in_schema = bool(kwargs.get("include_in_schema", True))
|
||||||
|
self.router = APIRouter(
|
||||||
|
prefix=self.prefix, tags=self.tags, include_in_schema=self.include_in_schema
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CreateEndpointFromCluster:
|
class CreateEndpointFromCluster:
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class TokenService:
|
|||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Handle employee login process and return login information."""
|
"""Handle employee login process and return login information."""
|
||||||
from ApiLayers.Schemas.identity.identity import UsersTokens, People
|
from ApiLayers.Schemas.identity.identity import UsersTokens, People
|
||||||
|
|
||||||
db_session = Employees.new_session()
|
db_session = Employees.new_session()
|
||||||
list_employee = Employees.filter_all(
|
list_employee = Employees.filter_all(
|
||||||
Employees.people_id == user.person_id, db=db_session
|
Employees.people_id == user.person_id, db=db_session
|
||||||
|
|||||||
@@ -26,7 +26,13 @@ class EndpointSuccessListResponse(BaseEndpointResponse): # 200 OK
|
|||||||
def as_dict(self, data: Optional[dict] = None, pagination: Optional[dict] = None):
|
def as_dict(self, data: Optional[dict] = None, pagination: Optional[dict] = None):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=status.HTTP_200_OK,
|
status_code=status.HTTP_200_OK,
|
||||||
content=dict(completed=True, **self.response, lang=self.lang, pagination=pagination, data=data),
|
content=dict(
|
||||||
|
completed=True,
|
||||||
|
**self.response,
|
||||||
|
lang=self.lang,
|
||||||
|
pagination=pagination,
|
||||||
|
data=data,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
accountResponses = {
|
accountResponses = {
|
||||||
"ACCOUNTS_LIST": {
|
"ACCOUNTS_LIST": {
|
||||||
"tr": {
|
"tr": {
|
||||||
|
|||||||
227
ApiLayers/LanguageModels/Response/how_to.py
Normal file
227
ApiLayers/LanguageModels/Response/how_to.py
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
from Events.Engine import MethodToEvent
|
||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
# from .account_records import (
|
||||||
|
# AccountRecordsUpdateEventMethods,
|
||||||
|
# AccountRecordsCreateEventMethods,
|
||||||
|
# AccountRecordsListEventMethods,
|
||||||
|
# )
|
||||||
|
|
||||||
|
cluster_name = "AccountCluster"
|
||||||
|
prefix = "/accounts"
|
||||||
|
|
||||||
|
|
||||||
|
class AccountRecordsUpdateEventMethods(MethodToEvent):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AccountRecordsCreateEventMethods(MethodToEvent):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AccountRecordsListEventMethods(MethodToEvent):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LanguageModels:
|
||||||
|
SITE_URL: str
|
||||||
|
COMPONENT: str = "Table"
|
||||||
|
PREFIX_URL: str = ""
|
||||||
|
PAGE_INFO: dict
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return {
|
||||||
|
"SITE_URL": self.SITE_URL,
|
||||||
|
"COMPONENT": self.COMPONENT,
|
||||||
|
"PREFIX_URL": self.PREFIX_URL,
|
||||||
|
"PAGE_INFO": self.PAGE_INFO,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
account_language_update_models = LanguageModels()
|
||||||
|
account_language_update_models.COMPONENT = "Link"
|
||||||
|
account_language_update_models.SITE_URL = f"/update?site={cluster_name}"
|
||||||
|
account_language_update_models.PREFIX_URL = (
|
||||||
|
f"{prefix}{AccountRecordsUpdateEventMethods.URL}"
|
||||||
|
)
|
||||||
|
account_language_update_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "Update Account Records",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Hesap Kayıdı Güncelle",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
account_language_model_as_dict = account_language_update_models.as_dict()
|
||||||
|
|
||||||
|
|
||||||
|
account_language_created_models = LanguageModels()
|
||||||
|
account_language_created_models.COMPONENT = "Link"
|
||||||
|
account_language_created_models.SITE_URL = f"/create?site={cluster_name}"
|
||||||
|
account_language_created_models.PREFIX_URL = (
|
||||||
|
f"{prefix}{AccountRecordsCreateEventMethods.URL}"
|
||||||
|
)
|
||||||
|
account_language_created_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "Create Account Records",
|
||||||
|
},
|
||||||
|
"tr": {"page": "Hesap Kayıdı Oluştur"},
|
||||||
|
}
|
||||||
|
account_language_created_models_as_dict = account_language_created_models.as_dict()
|
||||||
|
|
||||||
|
account_language_list_models = LanguageModels()
|
||||||
|
account_language_list_models.COMPONENT = "Table"
|
||||||
|
account_language_list_models.SITE_URL = f"/list?site={cluster_name}"
|
||||||
|
account_language_list_models.PREFIX_URL = (
|
||||||
|
f"{prefix}{AccountRecordsListEventMethods.URL}"
|
||||||
|
)
|
||||||
|
account_language_list_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "List Account Records",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Hesap Kayıtlarını Listele",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
account_language_list_models_as_dict = account_language_list_models.as_dict()
|
||||||
|
|
||||||
|
account_language_create_models = LanguageModels()
|
||||||
|
account_language_create_models.COMPONENT = "Form"
|
||||||
|
account_language_create_models.SITE_URL = f"/create?site={cluster_name}"
|
||||||
|
account_language_create_models.PREFIX_URL = (
|
||||||
|
f"{prefix}{AccountRecordsListEventMethods.URL}"
|
||||||
|
)
|
||||||
|
account_language_create_models.PAGE_INFO = {
|
||||||
|
"en": {"page": "List Account Records", "button:": "Create"},
|
||||||
|
"tr": {"page": "Hesap Kayıtlarını Listele", "button:": "Oluştur"},
|
||||||
|
}
|
||||||
|
|
||||||
|
account_language_create_models_as_dict = account_language_create_models.as_dict()
|
||||||
|
|
||||||
|
account_language_update_form_models = LanguageModels()
|
||||||
|
account_language_update_form_models.COMPONENT = "Form"
|
||||||
|
account_language_update_form_models.SITE_URL = f"/update?site={cluster_name}"
|
||||||
|
account_language_update_form_models.PREFIX_URL = (
|
||||||
|
f"{prefix}{AccountRecordsUpdateEventMethods.URL}"
|
||||||
|
)
|
||||||
|
account_language_update_form_models.PAGE_INFO = {
|
||||||
|
"en": {"page": "Update Account Records", "button:": "Update"},
|
||||||
|
"tr": {"page": "Hesap Kayıdı Güncelle", "button:": "Güncelle"},
|
||||||
|
}
|
||||||
|
account_language_update_form_models_as_dict = (
|
||||||
|
account_language_update_form_models.as_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
create_key = f"{prefix}{AccountRecordsCreateEventMethods.URL}"
|
||||||
|
update_key = f"{prefix}{AccountRecordsUpdateEventMethods.URL}"
|
||||||
|
list_key = f"{prefix}{AccountRecordsListEventMethods.URL}"
|
||||||
|
|
||||||
|
|
||||||
|
dashboard_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=f"/dashboard?site={cluster_name}",
|
||||||
|
icon="Building",
|
||||||
|
instructions={
|
||||||
|
str(list_key): {
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": "/validations/header",
|
||||||
|
"data": {"event_code": f"{prefix}/list", "asked_field": "headers"},
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"store": True,
|
||||||
|
"url": f"{prefix}/list",
|
||||||
|
"data": dict(page=1, limit=1),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
page_info={
|
||||||
|
"page": {
|
||||||
|
"en": "Account Records for reaching user all types account information",
|
||||||
|
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(list_key): AccountRecordsListEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
account_language_update_models.PREFIX_URL: account_language_model_as_dict,
|
||||||
|
account_language_created_models.PREFIX_URL: account_language_created_models_as_dict,
|
||||||
|
account_language_list_models.PREFIX_URL: account_language_list_models_as_dict,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
create_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=f"/create?site={cluster_name}",
|
||||||
|
icon="Building",
|
||||||
|
instructions={
|
||||||
|
str(create_key): {
|
||||||
|
"validation": {
|
||||||
|
"store": True,
|
||||||
|
"url": "/validations/validation",
|
||||||
|
"data": {"event_code": f"{prefix}/create", "asked_field": "validation"},
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": "/validations/header",
|
||||||
|
"data": {"event_code": f"{prefix}/create", "asked_field": "headers"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
page_info={
|
||||||
|
"page": {
|
||||||
|
"en": "Account Records creating for user all types account information",
|
||||||
|
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları oluştur",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
account_language_create_models.PREFIX_URL: account_language_create_models_as_dict,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
update_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=f"/update?site={cluster_name}",
|
||||||
|
icon="Building",
|
||||||
|
instructions={
|
||||||
|
str(update_key): {
|
||||||
|
"validation": {
|
||||||
|
"store": True,
|
||||||
|
"url": "/validations/validation",
|
||||||
|
"data": {"event_code": f"{prefix}/update", "asked_field": "validation"},
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": "/validations/header",
|
||||||
|
"data": {"event_code": f"{prefix}/update", "asked_field": "headers"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
page_info={
|
||||||
|
"page": {
|
||||||
|
"en": "Account Records updating for user all types account information",
|
||||||
|
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları güncelle",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
account_language_update_form_models.PREFIX_URL: account_language_update_form_models_as_dict,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
account_page_info = {
|
||||||
|
f"/dashboard?site={cluster_name}": dashboard_page_info,
|
||||||
|
f"/create?site={cluster_name}": create_page_info,
|
||||||
|
f"/update?site={cluster_name}": update_page_info,
|
||||||
|
}
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
import Events.AllEvents.authentication as auths_events
|
import Events.AllEvents.authentication as auths_events
|
||||||
|
|
||||||
|
|
||||||
events_list = (auths_events,)
|
events_list = (auths_events,)
|
||||||
|
|
||||||
|
|
||||||
|
def retrieve_cluster_by_name(cluster_name: str):
|
||||||
|
for module in events_list:
|
||||||
|
if hasattr(module, cluster_name):
|
||||||
|
return getattr(module, cluster_name, None)
|
||||||
|
return
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
import Events.AllEvents.events as events_events
|
import Events.AllEvents.events as events_events
|
||||||
|
|
||||||
|
|
||||||
events_list = (events_events,)
|
events_list = (events_events,)
|
||||||
|
|
||||||
|
|
||||||
|
def retrieve_cluster_by_name(cluster_name: str):
|
||||||
|
for module in events_list:
|
||||||
|
if hasattr(module, cluster_name):
|
||||||
|
return getattr(module, cluster_name, None)
|
||||||
|
return
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ COPY Events/AllEvents/validations /app/Events/AllEvents/validations
|
|||||||
COPY Events/base_request_model.py /app/Events/base_request_model.py
|
COPY Events/base_request_model.py /app/Events/base_request_model.py
|
||||||
COPY DockerApiServices/ValidationServiceApi/events_file.py /app/Events/AllEvents/events_file.py
|
COPY DockerApiServices/ValidationServiceApi/events_file.py /app/Events/AllEvents/events_file.py
|
||||||
|
|
||||||
|
COPY Events/AllEvents /app/Events/JustEvents
|
||||||
|
COPY Events/AllEvents/just_events_file.py /app/Events/JustEvents/events_file.py
|
||||||
|
|
||||||
# Set Python path to include app directory
|
# Set Python path to include app directory
|
||||||
ENV PYTHONPATH=/app \
|
ENV PYTHONPATH=/app \
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
import Events.AllEvents.validations as validations_events
|
import Events.AllEvents.validations as validations_events
|
||||||
|
|
||||||
events_list = (validations_events,)
|
events_list = (validations_events,)
|
||||||
|
|
||||||
|
|
||||||
|
def retrieve_cluster_by_name(cluster_name: str):
|
||||||
|
for module in events_list:
|
||||||
|
if hasattr(module, cluster_name):
|
||||||
|
return getattr(module, cluster_name, None)
|
||||||
|
return
|
||||||
|
|||||||
@@ -225,8 +225,12 @@ class AuthenticationFunctions(BaseRouteModel):
|
|||||||
request: FastAPI request object
|
request: FastAPI request object
|
||||||
data: Request body containing login credentials
|
data: Request body containing login credentials
|
||||||
{
|
{
|
||||||
"domain": "evyos.com.tr", "access_key": "karatay.berkay.sup@evyos.com.tr",
|
"data": {
|
||||||
"password": "string", "remember_me": false
|
"domain": "evyos.com.tr",
|
||||||
|
"access_key": "karatay.berkay.sup@evyos.com.tr",
|
||||||
|
"password": "string",
|
||||||
|
"remember_me": false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Returns:
|
Returns:
|
||||||
SuccessResponse containing authentication token and user info
|
SuccessResponse containing authentication token and user info
|
||||||
@@ -247,6 +251,13 @@ class AuthenticationFunctions(BaseRouteModel):
|
|||||||
"""
|
"""
|
||||||
Handle selection of company or occupant type
|
Handle selection of company or occupant type
|
||||||
{"data": {"build_living_space_uu_id": ""}} | {"data": {"company_uu_id": ""}}
|
{"data": {"build_living_space_uu_id": ""}} | {"data": {"company_uu_id": ""}}
|
||||||
|
{
|
||||||
|
"data": {"company_uu_id": "e9869a25-ba4d-49dc-bb0d-8286343b184b"}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"data": {"build_living_space_uu_id": "e9869a25-ba4d-49dc-bb0d-8286343b184b"}
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
selection_dict = dict(
|
selection_dict = dict(
|
||||||
request=cls.context_retriever.request,
|
request=cls.context_retriever.request,
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from Events.Engine.abstract_class import PageInfo
|
|||||||
|
|
||||||
authentication_page_info = PageInfo(
|
authentication_page_info = PageInfo(
|
||||||
name="Authentication",
|
name="Authentication",
|
||||||
title={"en": "Authentication", "tr": "Kimlik Doğrulama"},
|
|
||||||
description={"en": "User&Event Authentication for users", "tr": "Kullanıcı ve Etkinlik Kimlik Doğrulama"},
|
|
||||||
icon="",
|
|
||||||
parent="",
|
|
||||||
url="",
|
url="",
|
||||||
|
language_models={},
|
||||||
|
endpoints={},
|
||||||
|
icon="Authentication",
|
||||||
|
sub_components=[],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
Events package initialization.
|
Events package initialization.
|
||||||
"""
|
"""
|
||||||
from .account.cluster import AccountCluster
|
|
||||||
|
|
||||||
__all__ = [
|
from .account.cluster import AccountCluster
|
||||||
"AccountCluster",
|
from .address.cluster import AddressCluster
|
||||||
]
|
|
||||||
|
|
||||||
|
__all__ = ["AccountCluster", "AddressCluster"]
|
||||||
|
|||||||
@@ -1,51 +1,124 @@
|
|||||||
"""
|
"""
|
||||||
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
|
||||||
|
|
||||||
from Events.Engine.abstract_class import MethodToEvent
|
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.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_list_event_endpoint
|
||||||
account_insert_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,35 +1,30 @@
|
|||||||
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.
|
||||||
"""
|
# """
|
||||||
neighborhood_code: str
|
# neighborhood_code: str
|
||||||
neighborhood_name: str
|
# neighborhood_name: str
|
||||||
type_code: str
|
# type_code: str
|
||||||
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_list_super_user_event",
|
||||||
key="36a165fe-a2f3-437b-80ee-1ee44670fe70",
|
key="7192c2aa-5352-4e36-98b3-dafb7d036a3d",
|
||||||
request_validator=ListOptions,
|
request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
response_validator=SelectResponseAccount,
|
# response_validator=SelectResponseAccount,
|
||||||
# language_models=[AccountRecords.__language_model__],
|
# language_models=[AccountRecords.__language_model__],
|
||||||
language_models=[],
|
language_models=[],
|
||||||
statics="ACCOUNTS_LIST",
|
statics="ACCOUNTS_LIST",
|
||||||
@@ -37,6 +32,46 @@ 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="31f4f32f-0cd4-4995-8a6a-f9f56335848a",
|
||||||
|
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="208e6273-17ef-44f0-814a-8098f816b63a",
|
||||||
|
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
|
||||||
|
|||||||
38
Events/AllEvents/events/account/bases.py
Normal file
38
Events/AllEvents/events/account/bases.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from Events.Engine.abstract_class import DefaultClusterName
|
||||||
|
|
||||||
|
|
||||||
|
cluster_name = "AccountCluster"
|
||||||
|
prefix = "/accounts"
|
||||||
|
icon = "Building"
|
||||||
|
|
||||||
|
|
||||||
|
# Keys for the cluster
|
||||||
|
class KeyValidations:
|
||||||
|
headers = "headers"
|
||||||
|
data = "data"
|
||||||
|
validation = "validations"
|
||||||
|
|
||||||
|
# Key URLS for the cluster
|
||||||
|
class KeyURLs:
|
||||||
|
validations = "/validations/validations"
|
||||||
|
|
||||||
|
# Keys for the cluster
|
||||||
|
class KeyBases:
|
||||||
|
create_key = f"{prefix}/create"
|
||||||
|
update_key = f"{prefix}/update"
|
||||||
|
list_key = f"{prefix}/list"
|
||||||
|
|
||||||
|
|
||||||
|
# Page Variations of the cluster
|
||||||
|
class PageBases:
|
||||||
|
CREATE = f"/create?{DefaultClusterName}={cluster_name}"
|
||||||
|
UPDATE = f"/update?{DefaultClusterName}={cluster_name}"
|
||||||
|
DASHBOARD = f"/dashboard?{DefaultClusterName}={cluster_name}"
|
||||||
|
|
||||||
|
|
||||||
|
# Match the keys with the pages
|
||||||
|
page_2_keys = {
|
||||||
|
KeyBases.create_key: PageBases.CREATE,
|
||||||
|
KeyBases.update_key: PageBases.UPDATE,
|
||||||
|
KeyBases.list_key: PageBases.DASHBOARD,
|
||||||
|
}
|
||||||
@@ -1,18 +1,26 @@
|
|||||||
from Events.Engine.abstract_class import CategoryCluster
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from .account_records import (
|
||||||
from .account_records import AccountRecordsEventMethods
|
AccountRecordsListEventMethods,
|
||||||
from .info import account_page_info
|
AccountRecordsCreateEventMethods,
|
||||||
|
AccountRecordsUpdateEventMethods,
|
||||||
|
)
|
||||||
|
from .bases import cluster_name, prefix, page_2_keys
|
||||||
|
from .info import page_infos
|
||||||
|
|
||||||
|
|
||||||
AccountCluster = CategoryCluster(
|
AccountCluster = CategoryCluster(
|
||||||
name="AccountCluster",
|
name=cluster_name,
|
||||||
tags=["accounts"],
|
tags=["Account Records"],
|
||||||
prefix="/accounts",
|
prefix=prefix,
|
||||||
description="Account Cluster",
|
description="Account Cluster Actions",
|
||||||
pageinfo=account_page_info,
|
pageinfo=page_infos,
|
||||||
endpoints={
|
endpoints={
|
||||||
"AccountRecordsEventMethods": AccountRecordsEventMethods,
|
"AccountRecordsCreateEventMethods": AccountRecordsCreateEventMethods,
|
||||||
|
"AccountRecordsUpdateEventMethods": AccountRecordsUpdateEventMethods,
|
||||||
|
"AccountRecordsListEventMethods": AccountRecordsListEventMethods,
|
||||||
},
|
},
|
||||||
|
mapping=page_2_keys,
|
||||||
include_in_schema=True,
|
include_in_schema=True,
|
||||||
sub_category=[],
|
sub_category=[],
|
||||||
|
is_client=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,9 +45,13 @@ class AccountListEventMethods(BaseRouteModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def account_records_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
def account_records_list(
|
||||||
|
cls, data: Optional[Union[dict, ListOptions]]
|
||||||
|
) -> PaginationResult:
|
||||||
list_options_base = ListOptionsBase(
|
list_options_base = ListOptionsBase(
|
||||||
table=AccountRecords, list_options=data, model_query=None,
|
table=AccountRecords,
|
||||||
|
list_options=data,
|
||||||
|
model_query=None,
|
||||||
)
|
)
|
||||||
db_session, query_options = list_options_base.init_list_options()
|
db_session, query_options = list_options_base.init_list_options()
|
||||||
if cls.context_retriever.token.is_occupant:
|
if cls.context_retriever.token.is_occupant:
|
||||||
@@ -58,15 +62,112 @@ class AccountListEventMethods(BaseRouteModel):
|
|||||||
).query
|
).query
|
||||||
elif cls.context_retriever.token.is_employee:
|
elif cls.context_retriever.token.is_employee:
|
||||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||||
AccountRecords.company_id ==
|
AccountRecords.company_id
|
||||||
cls.context_retriever.token.selected_company.company_id,
|
== cls.context_retriever.token.selected_company.company_id,
|
||||||
db=db_session,
|
db=db_session,
|
||||||
).query
|
).query
|
||||||
records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
||||||
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 AccountCreateEventMethods(BaseRouteModel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def account_records_create(cls, data: Any):
|
||||||
|
data_dict = data.excluded_dump()
|
||||||
|
db_session = AccountRecords.new_session()
|
||||||
|
if cls.context_retriever.token.is_occupant:
|
||||||
|
build_iban = BuildIbans.filter_one(
|
||||||
|
BuildIbans.iban == data.iban,
|
||||||
|
BuildIbans.build_id
|
||||||
|
== cls.context_retriever.token.selected_occupant.build_id,
|
||||||
|
db=db_session,
|
||||||
|
).data
|
||||||
|
if not build_iban:
|
||||||
|
raise BuildIbans.raise_http_exception(
|
||||||
|
status_code="HTTP_404_NOT_FOUND",
|
||||||
|
error_case="UNAUTHORIZED",
|
||||||
|
message=f"{data.iban} is not found in company related to your organization",
|
||||||
|
data={"iban": data.iban},
|
||||||
|
)
|
||||||
|
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
||||||
|
# return AlchemyJsonResponse(
|
||||||
|
# completed=True,
|
||||||
|
# message="Account record created successfully",
|
||||||
|
# result=account_record,
|
||||||
|
# )
|
||||||
|
elif cls.context_retriever.token.is_employee:
|
||||||
|
# Build.pre_query = Build.select_action(
|
||||||
|
# employee_id=token_dict.selected_employee.employee_id,
|
||||||
|
# )
|
||||||
|
# build_ids_list = Build.filter_all(
|
||||||
|
# )
|
||||||
|
# build_iban = BuildIbans.filter_one(
|
||||||
|
# BuildIbans.iban == data.iban,
|
||||||
|
# BuildIbans.build_id.in_([build.id for build in build_ids_list.data]),
|
||||||
|
# ).data
|
||||||
|
# if not build_iban:
|
||||||
|
# BuildIbans.raise_http_exception(
|
||||||
|
# status_code="HTTP_404_NOT_FOUND",
|
||||||
|
# error_case="UNAUTHORIZED",
|
||||||
|
# message=f"{data.iban} is not found in company related to your organization",
|
||||||
|
# data={
|
||||||
|
# "iban": data.iban,
|
||||||
|
# },
|
||||||
|
# )
|
||||||
|
bank_date = system_arrow.get(data.bank_date)
|
||||||
|
data_dict["bank_date_w"] = bank_date.weekday()
|
||||||
|
data_dict["bank_date_m"] = bank_date.month
|
||||||
|
data_dict["bank_date_d"] = bank_date.day
|
||||||
|
data_dict["bank_date_y"] = bank_date.year
|
||||||
|
|
||||||
|
if int(data.currency_value) < 0:
|
||||||
|
debit_type = ApiEnumDropdown.filter_by_one(
|
||||||
|
system=True, enum_class="DebitTypes", key="DT-D", db=db_session
|
||||||
|
).data
|
||||||
|
data_dict["receive_debit"] = debit_type.id
|
||||||
|
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||||
|
else:
|
||||||
|
debit_type = ApiEnumDropdown.filter_by_one(
|
||||||
|
system=True, enum_class="DebitTypes", key="DT-R", db=db_session
|
||||||
|
).data
|
||||||
|
data_dict["receive_debit"] = debit_type.id
|
||||||
|
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||||
|
|
||||||
|
account_record = AccountRecords.find_or_create(
|
||||||
|
data_dict, db=db_session
|
||||||
|
).data
|
||||||
|
# return AlchemyJsonResponse(
|
||||||
|
# completed=True,
|
||||||
|
# message="Account record created successfully",
|
||||||
|
# result=account_record,
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
class AccountUpdateEventMethods(BaseRouteModel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def account_records_update(cls, build_uu_id: str, data: Any):
|
||||||
|
if cls.context_retriever.token.is_occupant:
|
||||||
|
pass
|
||||||
|
elif cls.context_retriever.token.is_employee:
|
||||||
|
pass
|
||||||
|
AccountRecords.build_parts_id = (
|
||||||
|
cls.context_retriever.token.selected_occupant.build_part_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# return AlchemyJsonResponse(
|
||||||
|
# completed=True,
|
||||||
|
# message="Account record updated successfully",
|
||||||
|
# result=account_record,
|
||||||
|
# cls_object=AccountRecords,
|
||||||
|
# response_model=UpdateAccountRecord,
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
# @classmethod
|
# @classmethod
|
||||||
# def account_records_list_flt_res(cls, list_options: ListOptions) -> PaginationResult:
|
# def account_records_list_flt_res(cls, list_options: ListOptions) -> PaginationResult:
|
||||||
# list_options_base = ListOptionsBase(
|
# list_options_base = ListOptionsBase(
|
||||||
@@ -202,92 +303,3 @@ class AccountListEventMethods(BaseRouteModel):
|
|||||||
# response_model=AccountRecordResponse,
|
# response_model=AccountRecordResponse,
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
class AccountCreateEventMethods(BaseRouteModel):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def account_records_create(cls, data: Any):
|
|
||||||
data_dict = data.excluded_dump()
|
|
||||||
db_session = AccountRecords.new_session()
|
|
||||||
if cls.context_retriever.token.is_occupant:
|
|
||||||
build_iban = BuildIbans.filter_one(
|
|
||||||
BuildIbans.iban == data.iban,
|
|
||||||
BuildIbans.build_id == cls.context_retriever.token.selected_occupant.build_id,
|
|
||||||
db=db_session,
|
|
||||||
).data
|
|
||||||
if not build_iban:
|
|
||||||
raise BuildIbans.raise_http_exception(
|
|
||||||
status_code="HTTP_404_NOT_FOUND",
|
|
||||||
error_case="UNAUTHORIZED",
|
|
||||||
message=f"{data.iban} is not found in company related to your organization",
|
|
||||||
data={"iban": data.iban},
|
|
||||||
)
|
|
||||||
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
|
||||||
# return AlchemyJsonResponse(
|
|
||||||
# completed=True,
|
|
||||||
# message="Account record created successfully",
|
|
||||||
# result=account_record,
|
|
||||||
# )
|
|
||||||
elif cls.context_retriever.token.is_employee:
|
|
||||||
# Build.pre_query = Build.select_action(
|
|
||||||
# employee_id=token_dict.selected_employee.employee_id,
|
|
||||||
# )
|
|
||||||
# build_ids_list = Build.filter_all(
|
|
||||||
# )
|
|
||||||
# build_iban = BuildIbans.filter_one(
|
|
||||||
# BuildIbans.iban == data.iban,
|
|
||||||
# BuildIbans.build_id.in_([build.id for build in build_ids_list.data]),
|
|
||||||
# ).data
|
|
||||||
# if not build_iban:
|
|
||||||
# BuildIbans.raise_http_exception(
|
|
||||||
# status_code="HTTP_404_NOT_FOUND",
|
|
||||||
# error_case="UNAUTHORIZED",
|
|
||||||
# message=f"{data.iban} is not found in company related to your organization",
|
|
||||||
# data={
|
|
||||||
# "iban": data.iban,
|
|
||||||
# },
|
|
||||||
# )
|
|
||||||
bank_date = system_arrow.get(data.bank_date)
|
|
||||||
data_dict["bank_date_w"] = bank_date.weekday()
|
|
||||||
data_dict["bank_date_m"] = bank_date.month
|
|
||||||
data_dict["bank_date_d"] = bank_date.day
|
|
||||||
data_dict["bank_date_y"] = bank_date.year
|
|
||||||
|
|
||||||
if int(data.currency_value) < 0:
|
|
||||||
debit_type = ApiEnumDropdown.filter_by_one(
|
|
||||||
system=True, enum_class="DebitTypes", key="DT-D", db=db_session
|
|
||||||
).data
|
|
||||||
data_dict["receive_debit"] = debit_type.id
|
|
||||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
|
||||||
else:
|
|
||||||
debit_type = ApiEnumDropdown.filter_by_one(
|
|
||||||
system=True, enum_class="DebitTypes", key="DT-R", db=db_session
|
|
||||||
).data
|
|
||||||
data_dict["receive_debit"] = debit_type.id
|
|
||||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
|
||||||
|
|
||||||
account_record = AccountRecords.find_or_create(data_dict, db=db_session).data
|
|
||||||
# return AlchemyJsonResponse(
|
|
||||||
# completed=True,
|
|
||||||
# message="Account record created successfully",
|
|
||||||
# result=account_record,
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class AccountUpdateEventMethods(BaseRouteModel):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def account_records_update(cls, build_uu_id: str, data: Any):
|
|
||||||
if cls.context_retriever.token.is_occupant:
|
|
||||||
pass
|
|
||||||
elif cls.context_retriever.token.is_employee:
|
|
||||||
pass
|
|
||||||
AccountRecords.build_parts_id = cls.context_retriever.token.selected_occupant.build_part_id
|
|
||||||
account_record = AccountRecords.update_one(build_uu_id, data).data
|
|
||||||
# return AlchemyJsonResponse(
|
|
||||||
# completed=True,
|
|
||||||
# message="Account record updated successfully",
|
|
||||||
# result=account_record,
|
|
||||||
# cls_object=AccountRecords,
|
|
||||||
# response_model=UpdateAccountRecord,
|
|
||||||
# )
|
|
||||||
|
|||||||
@@ -1,14 +1,140 @@
|
|||||||
from Events.Engine.abstract_class import PageInfo
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
from .bases import KeyValidations, cluster_name, KeyBases, PageBases, icon, KeyURLs
|
||||||
|
from .account_records import (
|
||||||
account_page_info = PageInfo(
|
AccountRecordsUpdateEventMethods,
|
||||||
name="Accounts",
|
AccountRecordsCreateEventMethods,
|
||||||
title={"en": "Account Records", "tr": "Hesap Kayıtları"},
|
AccountRecordsListEventMethods,
|
||||||
description={
|
|
||||||
"en": "Account Records for reaching user all types account information",
|
|
||||||
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları"
|
|
||||||
},
|
|
||||||
icon="",
|
|
||||||
parent="",
|
|
||||||
url="",
|
|
||||||
)
|
)
|
||||||
|
from .lang_models import (
|
||||||
|
account_language_create_models_as_dict,
|
||||||
|
account_language_model_as_dict,
|
||||||
|
account_language_list_models_as_dict,
|
||||||
|
account_language_created_models_as_dict,
|
||||||
|
account_language_update_form_models_as_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ClustersPageInfo:
|
||||||
|
|
||||||
|
# Cluster Page Infos that are available for the client
|
||||||
|
dashboard_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=PageBases.DASHBOARD,
|
||||||
|
icon=icon,
|
||||||
|
page_info={
|
||||||
|
"en": {
|
||||||
|
"page": "Account Records for reaching user all types account information",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
instructions={
|
||||||
|
str(KeyBases.list_key): {
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": KeyURLs.validations,
|
||||||
|
"data": {"event_code": f"{KeyBases.list_key}", "asked_field": KeyValidations.headers},
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"store": True,
|
||||||
|
"url": f"{KeyBases.list_key}",
|
||||||
|
"data": dict(page=1, limit=1),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(KeyBases.update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(KeyBases.create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(KeyBases.list_key): AccountRecordsListEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
str(KeyBases.list_key): {
|
||||||
|
str(KeyBases.update_key): account_language_model_as_dict,
|
||||||
|
str(KeyBases.create_key): account_language_created_models_as_dict,
|
||||||
|
str(KeyBases.list_key): account_language_list_models_as_dict,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
create_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=PageBases.CREATE,
|
||||||
|
icon=icon,
|
||||||
|
instructions={
|
||||||
|
str(KeyBases.create_key): {
|
||||||
|
"validation": {
|
||||||
|
"store": True,
|
||||||
|
"url": KeyURLs.validations,
|
||||||
|
"data": {"event_code": f"{KeyBases.create_key}", "asked_field": KeyValidations.validation },
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": KeyURLs.validations,
|
||||||
|
"data": {"event_code": f"{KeyBases.create_key}", "asked_field": KeyValidations.headers},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
page_info={
|
||||||
|
"en": {
|
||||||
|
"page": "Create Account Records for reaching user all types account information",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıt Oluştur",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(KeyBases.create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
str(KeyBases.create_key): account_language_create_models_as_dict,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
update_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=PageBases.UPDATE,
|
||||||
|
icon=icon,
|
||||||
|
instructions={
|
||||||
|
str(KeyBases.update_key): {
|
||||||
|
"validation": {
|
||||||
|
"store": True,
|
||||||
|
"url": KeyURLs.validations,
|
||||||
|
"data": {"event_code": f"{KeyBases.update_key}", "asked_field": KeyValidations.validation},
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"store": True,
|
||||||
|
"url": KeyURLs.validations,
|
||||||
|
"data": {"event_code": f"{KeyBases.update_key}", "asked_field": KeyValidations.headers},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
page_info={
|
||||||
|
"en": {
|
||||||
|
"page": "Update Account Records via all types account information",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Tüm hesap bilgileri aracılığıyla Hesap Kayıtlarını Güncelle",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
endpoints={
|
||||||
|
str(KeyBases.update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
str(KeyBases.update_key): account_language_update_form_models_as_dict,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Page Variations of the cluster
|
||||||
|
page_infos = {
|
||||||
|
ClustersPageInfo.dashboard_page_info.URL: ClustersPageInfo.dashboard_page_info,
|
||||||
|
ClustersPageInfo.create_page_info.URL: ClustersPageInfo.create_page_info,
|
||||||
|
ClustersPageInfo.update_page_info.URL: ClustersPageInfo.update_page_info,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Check if all the page info is implemented in the mappings
|
||||||
|
for t in [x for k, x in PageBases.__dict__.items() if not str(k).startswith("__")]:
|
||||||
|
if t not in list(dict(page_infos).keys()):
|
||||||
|
raise NotImplementedError(f"Page Info of : {t} is not implemented in mappings")
|
||||||
|
|||||||
78
Events/AllEvents/events/account/lang_models.py
Normal file
78
Events/AllEvents/events/account/lang_models.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
from Events.Engine.abstract_class import DefaultClusterName, LanguageModels
|
||||||
|
from .bases import KeyBases, cluster_name
|
||||||
|
|
||||||
|
|
||||||
|
account_language_update_models = LanguageModels()
|
||||||
|
account_language_update_models.COMPONENT = "Link"
|
||||||
|
account_language_update_models.SITE_URL = f"/update?{DefaultClusterName}={cluster_name}"
|
||||||
|
account_language_update_models.PREFIX_URL = (
|
||||||
|
KeyBases.update_key
|
||||||
|
)
|
||||||
|
account_language_update_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "Update Account Records",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Hesap Kayıdı Güncelle",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
account_language_model_as_dict = account_language_update_models.as_dict()
|
||||||
|
|
||||||
|
|
||||||
|
account_language_created_models = LanguageModels()
|
||||||
|
account_language_created_models.COMPONENT = "Link"
|
||||||
|
account_language_created_models.SITE_URL = f"/create?{DefaultClusterName}={cluster_name}"
|
||||||
|
account_language_created_models.PREFIX_URL = (
|
||||||
|
KeyBases.create_key
|
||||||
|
)
|
||||||
|
account_language_created_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "Create Account Records",
|
||||||
|
},
|
||||||
|
"tr": {"page": "Hesap Kayıdı Oluştur"},
|
||||||
|
}
|
||||||
|
account_language_created_models_as_dict = account_language_created_models.as_dict()
|
||||||
|
|
||||||
|
account_language_list_models = LanguageModels()
|
||||||
|
account_language_list_models.COMPONENT = "Table"
|
||||||
|
account_language_list_models.SITE_URL = f"/dashboard?{DefaultClusterName}={cluster_name}"
|
||||||
|
account_language_list_models.PREFIX_URL = (
|
||||||
|
KeyBases.list_key
|
||||||
|
)
|
||||||
|
account_language_list_models.PAGE_INFO = {
|
||||||
|
"en": {
|
||||||
|
"page": "List Account Records",
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"page": "Hesap Kayıtlarını Listele",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
account_language_list_models_as_dict = account_language_list_models.as_dict()
|
||||||
|
|
||||||
|
account_language_create_form_models = LanguageModels()
|
||||||
|
account_language_create_form_models.COMPONENT = "Form"
|
||||||
|
account_language_create_form_models.SITE_URL = f"/create?{DefaultClusterName}={cluster_name}"
|
||||||
|
account_language_create_form_models.PREFIX_URL = (
|
||||||
|
KeyBases.create_key
|
||||||
|
)
|
||||||
|
account_language_create_form_models.PAGE_INFO = {
|
||||||
|
"en": {"page": "List Account Records", "button:": "Create"},
|
||||||
|
"tr": {"page": "Hesap Kayıtlarını Listele", "button:": "Oluştur"},
|
||||||
|
}
|
||||||
|
|
||||||
|
account_language_create_models_as_dict = account_language_create_form_models.as_dict()
|
||||||
|
|
||||||
|
account_language_update_form_models = LanguageModels()
|
||||||
|
account_language_update_form_models.COMPONENT = "Form"
|
||||||
|
account_language_update_form_models.SITE_URL = f"/update?{DefaultClusterName}={cluster_name}"
|
||||||
|
account_language_update_form_models.PREFIX_URL = (
|
||||||
|
KeyBases.update_key
|
||||||
|
)
|
||||||
|
account_language_update_form_models.PAGE_INFO = {
|
||||||
|
"en": {"page": "Update Account Records", "button:": "Update"},
|
||||||
|
"tr": {"page": "Hesap Kayıdı Güncelle", "button:": "Güncelle"},
|
||||||
|
}
|
||||||
|
account_language_update_form_models_as_dict = (
|
||||||
|
account_language_update_form_models.as_dict()
|
||||||
|
)
|
||||||
@@ -2,10 +2,9 @@
|
|||||||
Account records request and response models.
|
Account records request and response models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, Any, Optional
|
from typing import Optional
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from ApiLayers.ApiValidations.Request import PydanticBaseModel
|
from ApiLayers.ApiValidations.Request import PydanticBaseModel, ListOptions
|
||||||
|
|
||||||
|
|
||||||
class InsertAccountRecord(PydanticBaseModel):
|
class InsertAccountRecord(PydanticBaseModel):
|
||||||
@@ -88,44 +87,8 @@ class UpdateAccountRecord(PydanticBaseModel):
|
|||||||
build_decision_book_uu_id: Optional[str] = None
|
build_decision_book_uu_id: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class ListAccountRecord(PydanticBaseModel):
|
class ListAccountRecord(ListOptions):
|
||||||
|
pass
|
||||||
iban: Optional[str] = None
|
|
||||||
bank_date: Optional[str] = None
|
|
||||||
currency_value: Optional[float] = None
|
|
||||||
bank_balance: Optional[float] = None
|
|
||||||
currency: Optional[str] = None
|
|
||||||
additional_balance: Optional[float] = None
|
|
||||||
channel_branch: Optional[str] = None
|
|
||||||
process_name: Optional[str] = None
|
|
||||||
process_type: Optional[str] = None
|
|
||||||
process_comment: Optional[str] = None
|
|
||||||
bank_reference_code: Optional[str] = None
|
|
||||||
|
|
||||||
add_comment_note: Optional[str] = None
|
|
||||||
is_receipt_mail_send: Optional[bool] = None
|
|
||||||
found_from: Optional[str] = None
|
|
||||||
similarity: Optional[float] = None
|
|
||||||
remainder_balance: Optional[float] = None
|
|
||||||
bank_date_y: Optional[int] = None
|
|
||||||
bank_date_m: Optional[int] = None
|
|
||||||
bank_date_w: Optional[int] = None
|
|
||||||
bank_date_d: Optional[int] = None
|
|
||||||
approving_accounting_record: Optional[bool] = None
|
|
||||||
accounting_receipt_date: Optional[str] = None
|
|
||||||
accounting_receipt_number: Optional[int] = None
|
|
||||||
approved_record: Optional[bool] = None
|
|
||||||
import_file_name: Optional[str] = None
|
|
||||||
receive_debit_uu_id: Optional[str] = None
|
|
||||||
budget_type_uu_id: Optional[str] = None
|
|
||||||
company_uu_id: Optional[str] = None
|
|
||||||
send_company_uu_id: Optional[str] = None
|
|
||||||
customer_id: Optional[str] = None
|
|
||||||
customer_uu_id: Optional[str] = None
|
|
||||||
send_person_uu_id: Optional[str] = None
|
|
||||||
approving_accounting_person_uu_id: Optional[str] = None
|
|
||||||
build_parts_uu_id: Optional[str] = None
|
|
||||||
build_decision_book_uu_id: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class AccountRequestValidators:
|
class AccountRequestValidators:
|
||||||
|
|||||||
@@ -1,351 +1,166 @@
|
|||||||
"""
|
"""
|
||||||
request models.
|
Account related API endpoints.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, Any, List, Optional, TypedDict, Union
|
from typing import Any, Dict
|
||||||
from pydantic import BaseModel, Field, model_validator, RootModel, ConfigDict
|
|
||||||
from ApiEvents.abstract_class import MethodToEvent
|
|
||||||
from ApiEvents.base_request_model import BaseRequestModel, DictRequestModel
|
|
||||||
from ApiValidations.Custom.token_objects import EmployeeTokenObject, OccupantTokenObject
|
|
||||||
from ApiValidations.Request.address import SearchAddress, UpdateAddress
|
|
||||||
from ApiValidations.Request.base_validations import ListOptions
|
|
||||||
from ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
|
||||||
from Schemas.identity.identity import (
|
|
||||||
AddressPostcode,
|
|
||||||
AddressStreet,
|
|
||||||
Addresses,
|
|
||||||
RelationshipEmployee2PostCode,
|
|
||||||
)
|
|
||||||
from ApiValidations.Request import (
|
|
||||||
InsertAddress,
|
|
||||||
)
|
|
||||||
from ApiValidations.Response import (
|
|
||||||
ListAddressResponse,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
||||||
|
from Events.Engine.abstract_class import MethodToEvent
|
||||||
|
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
||||||
|
|
||||||
class AddressListEventMethod(MethodToEvent):
|
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||||
|
from ApiLayers.ApiValidations.Response.default_response import (
|
||||||
event_type = "SELECT"
|
EndpointSuccessListResponse,
|
||||||
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 = [
|
|
||||||
street_id[0]
|
|
||||||
for street_id in AddressPostcode.select_only(
|
|
||||||
AddressPostcode.id.in_(post_code_id_list),
|
|
||||||
select_args=[AddressPostcode.street_id],
|
|
||||||
order_by=AddressPostcode.street_id.desc(),
|
|
||||||
db=db,
|
|
||||||
).data
|
|
||||||
]
|
|
||||||
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()
|
from .function_handlers import (
|
||||||
data_dict["street_id"] = post_code.street_id
|
AddressListFunctions,
|
||||||
data_dict["street_uu_id"] = str(post_code.street_uu_id)
|
AddressUpdateFunctions,
|
||||||
del data_dict["post_code_uu_id"]
|
AddressSearchFunctions,
|
||||||
address = Addresses.find_or_create(**data_dict)
|
AddressCreateFunctions,
|
||||||
address.save()
|
)
|
||||||
address.update(is_confirmed=True)
|
from .api_events import AddressSuperUserEvents
|
||||||
address.save()
|
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True,
|
AddressListEventMethods = MethodToEvent(
|
||||||
message="Address created successfully",
|
name="AddressListEventMethods",
|
||||||
result=address.get_dict(),
|
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",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AddressSearchEventMethod(MethodToEvent):
|
def account_list_event_endpoint(
|
||||||
"""Event methods for searching addresses.
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
This class handles address search functionality including text search
|
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||||
and filtering.
|
event_2_catch = AddressListEventMethods.retrieve_event(
|
||||||
"""
|
event_function_code=f"{AddressSuperUserEvents.AddressListEvents.key}"
|
||||||
|
)
|
||||||
event_type = "SEARCH"
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
event_description = "Search for addresses using text and filters"
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
event_category = "Address"
|
AddressListFunctions.context_retriever = context_retriever
|
||||||
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
__event_keys__ = {
|
return EndpointSuccessListResponse(
|
||||||
"e0ac1269-e9a7-4806-9962-219ac224b0d0": "search_address",
|
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||||
}
|
).as_dict(
|
||||||
__event_validation__ = {
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
"e0ac1269-e9a7-4806-9962-219ac224b0d0": (
|
|
||||||
SearchAddress,
|
|
||||||
[Addresses.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _build_order_clause(
|
|
||||||
cls, filter_list: Dict[str, Any], schemas: List[str], filter_table: Any
|
|
||||||
) -> Any:
|
|
||||||
"""Build the ORDER BY clause for the query.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
filter_list: Dictionary of filter options
|
|
||||||
schemas: List of available schema fields
|
|
||||||
filter_table: SQLAlchemy table to query
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
SQLAlchemy order_by clause
|
|
||||||
"""
|
|
||||||
# Default to ordering by UUID if field not in schema
|
|
||||||
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:
|
AddressListEventMethods.endpoint_callable = account_list_event_endpoint
|
||||||
record: Database record to format
|
|
||||||
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
|
AddressCreateEventMethods = MethodToEvent(
|
||||||
def search_address(
|
name="AddressCreateEventMethods",
|
||||||
cls,
|
events={
|
||||||
data: SearchAddress,
|
AddressSuperUserEvents.AddressCreateEvents.key: AddressSuperUserEvents.AddressCreateEvents,
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
},
|
||||||
) -> Any:
|
headers=[],
|
||||||
"""Search for addresses using text search and filters.
|
errors=[],
|
||||||
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
Args:
|
url="/create",
|
||||||
data: Search parameters including text and filters
|
method="POST",
|
||||||
token_dict: Authentication token
|
summary="Create Address via given data and previligous",
|
||||||
|
description="Create Address via given data and previligous",
|
||||||
Returns:
|
|
||||||
JSON response with search results
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
HTTPExceptionApi: If search fails
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
# Start performance measurement
|
|
||||||
start_time = perf_counter()
|
|
||||||
|
|
||||||
# Get initial query
|
|
||||||
search_result = AddressStreet.search_address_text(search_text=data.search)
|
|
||||||
if not search_result:
|
|
||||||
raise HTTPExceptionApi(
|
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
|
||||||
detail="No addresses found matching search criteria",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
query = search_result.get("query")
|
|
||||||
schemas = search_result.get("schema")
|
|
||||||
|
|
||||||
# Apply filters
|
def account_create_event_endpoint(
|
||||||
filter_list = data.list_options.dump()
|
request: Request, data: EndpointBaseRequestModel
|
||||||
filter_table = AddressStreet
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_create_event_endpoint)
|
||||||
# Build and apply order clause
|
event_2_catch = AddressCreateEventMethods.retrieve_event(
|
||||||
order = cls._build_order_clause(filter_list, schemas, filter_table)
|
event_function_code=f"{AddressSuperUserEvents.AddressCreateEvents.key}"
|
||||||
|
|
||||||
# Apply pagination
|
|
||||||
page_size = int(filter_list.get("size"))
|
|
||||||
offset = (int(filter_list.get("page")) - 1) * page_size
|
|
||||||
|
|
||||||
# Execute query
|
|
||||||
query = (
|
|
||||||
query.order_by(order)
|
|
||||||
.limit(page_size)
|
|
||||||
.offset(offset)
|
|
||||||
.populate_existing()
|
|
||||||
)
|
)
|
||||||
records = list(query.all())
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
# Format results
|
AddressCreateFunctions.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:
|
|
||||||
# Re-raise HTTP exceptions
|
AddressCreateEventMethods.endpoint_callable = account_create_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):
|
AddressUpdateEventMethods = MethodToEvent(
|
||||||
|
name="AddressUpdateEventMethods",
|
||||||
event_type = "UPDATE"
|
events={
|
||||||
event_description = ""
|
AddressSuperUserEvents.AddressUpdateEvents.key: AddressSuperUserEvents.AddressUpdateEvents,
|
||||||
event_category = ""
|
},
|
||||||
|
headers=[],
|
||||||
__event_keys__ = {
|
errors=[],
|
||||||
"1f9c3a9c-e5bd-4dcd-9b9a-3742d7e03a27": "update_address",
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
}
|
url="/update",
|
||||||
__event_validation__ = {
|
method="POST",
|
||||||
"1f9c3a9c-e5bd-4dcd-9b9a-3742d7e03a27": (
|
summary="Update Address via given data and previligous",
|
||||||
UpdateAddress,
|
description="Update Address via given data and previligous",
|
||||||
[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)
|
def account_update_event_endpoint(
|
||||||
updated_address.save()
|
request: Request, data: EndpointBaseRequestModel
|
||||||
return AlchemyJsonResponse(
|
) -> Dict[str, Any]:
|
||||||
completed=True,
|
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||||
message="Address updated successfully",
|
event_2_catch = AddressUpdateEventMethods.retrieve_event(
|
||||||
result=updated_address.get_dict(),
|
event_function_code=f"{AddressSuperUserEvents.AddressUpdateEvents.key}"
|
||||||
)
|
)
|
||||||
elif isinstance(token_dict, OccupantTokenObject):
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
raise HTTPExceptionApi(
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
status_code=403,
|
AddressUpdateFunctions.context_retriever = context_retriever
|
||||||
detail="Occupant can not update address.",
|
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()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AddressUpdateEventMethods.endpoint_callable = account_update_event_endpoint
|
||||||
|
|
||||||
|
|
||||||
|
AddressSearchEventMethods = MethodToEvent(
|
||||||
|
name="AddressSearchEventMethods",
|
||||||
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def address_search_event_endpoint(
|
||||||
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||||
|
event_2_catch = AddressUpdateEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{AddressSuperUserEvents.AddressSearchEvents.key}"
|
||||||
|
)
|
||||||
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
|
AddressSearchFunctions.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()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
AddressSearchEventMethods.endpoint_callable = address_search_event_endpoint
|
||||||
|
|||||||
85
Events/AllEvents/events/address/api_events.py
Normal file
85
Events/AllEvents/events/address/api_events.py
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
# from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from .function_handlers import AddressSuperUserFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Address List for super_user event
|
||||||
|
address_list_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="7ce855ce-db79-4397-b0ec-f5e408ea6447",
|
||||||
|
# request_validator=AccountRequestValidators.ListAccountRecord,
|
||||||
|
# response_validator=SelectResponseAccount,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="",
|
||||||
|
description="List address by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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="455b8bf5-52e4-47fa-9338-102bfcd364e5",
|
||||||
|
# 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="7dd8c122-fae5-4a6d-a439-068312bb4df3",
|
||||||
|
# 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
|
||||||
27
Events/AllEvents/events/address/cluster.py
Normal file
27
Events/AllEvents/events/address/cluster.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
|
||||||
|
from .address import (
|
||||||
|
AddressListEventMethods,
|
||||||
|
AddressCreateEventMethods,
|
||||||
|
AddressUpdateEventMethods,
|
||||||
|
AddressSearchEventMethods,
|
||||||
|
)
|
||||||
|
from .info import address_page_info
|
||||||
|
|
||||||
|
|
||||||
|
AddressCluster = CategoryCluster(
|
||||||
|
name="AddressCluster",
|
||||||
|
tags=["Address"],
|
||||||
|
prefix="/address",
|
||||||
|
description="Address Cluster",
|
||||||
|
pageinfo=address_page_info,
|
||||||
|
endpoints={
|
||||||
|
"AddressListEventMethods": AddressListEventMethods,
|
||||||
|
"AddressCreateEventMethods": AddressCreateEventMethods,
|
||||||
|
"AddressUpdateEventMethods": AddressUpdateEventMethods,
|
||||||
|
"AddressSearchEventMethods": AddressSearchEventMethods,
|
||||||
|
},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
is_client=True,
|
||||||
|
)
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
"""
|
|
||||||
Account records endpoint configurations.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from ApiEvents.abstract_class import (
|
|
||||||
RouteFactoryConfig,
|
|
||||||
EndpointFactoryConfig,
|
|
||||||
endpoint_wrapper,
|
|
||||||
)
|
|
||||||
from ApiEvents.base_request_model import EndpointBaseRequestModel
|
|
||||||
|
|
||||||
from Services.PostgresDb.Models.alchemy_response import DictJsonResponse
|
|
||||||
from fastapi import Request, Path, Body
|
|
||||||
|
|
||||||
|
|
||||||
@endpoint_wrapper("/address/list")
|
|
||||||
async def address_list(request: "Request", data: EndpointBaseRequestModel):
|
|
||||||
"""Handle address list endpoint."""
|
|
||||||
auth_dict = address_list.auth
|
|
||||||
code_dict = getattr(address_list, "func_code", {"function_code": None})
|
|
||||||
return {"auth_dict": auth_dict, "code_dict": code_dict, "data": data}
|
|
||||||
|
|
||||||
|
|
||||||
@endpoint_wrapper("/address/create")
|
|
||||||
async def address_create(request: "Request", data: EndpointBaseRequestModel):
|
|
||||||
"""Handle address creation endpoint."""
|
|
||||||
return {
|
|
||||||
"data": data,
|
|
||||||
"request": str(request.headers),
|
|
||||||
"request_url": str(request.url),
|
|
||||||
"request_base_url": str(request.base_url),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@endpoint_wrapper("/address/update/{address_uu_id}")
|
|
||||||
async def address_update(
|
|
||||||
request: Request,
|
|
||||||
address_uu_id: str = Path(..., description="UUID of the address to update"),
|
|
||||||
request_data: EndpointBaseRequestModel = Body(..., description="Request body"),
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Handle address update endpoint.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
request: FastAPI request object
|
|
||||||
address_uu_id: UUID of the address to update
|
|
||||||
request_data: Request body containing updated address data
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
DictJsonResponse: Response containing updated address info
|
|
||||||
"""
|
|
||||||
auth_dict = address_update.auth
|
|
||||||
return DictJsonResponse(
|
|
||||||
data={
|
|
||||||
"address_uu_id": address_uu_id,
|
|
||||||
"data": request_data.root,
|
|
||||||
"request": str(request.headers),
|
|
||||||
"request_url": str(request.url),
|
|
||||||
"request_base_url": str(request.base_url),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
prefix = "/address"
|
|
||||||
|
|
||||||
|
|
||||||
# Address Router Configuration
|
|
||||||
ADDRESS_CONFIG = RouteFactoryConfig(
|
|
||||||
name="address",
|
|
||||||
prefix=prefix,
|
|
||||||
tags=["Address"],
|
|
||||||
include_in_schema=True,
|
|
||||||
endpoints=[
|
|
||||||
EndpointFactoryConfig(
|
|
||||||
url_prefix=prefix,
|
|
||||||
url_endpoint="/list",
|
|
||||||
url_of_endpoint=f"{prefix}/list",
|
|
||||||
endpoint="/list",
|
|
||||||
method="POST",
|
|
||||||
summary="List Active/Delete/Confirm Address",
|
|
||||||
description="List Active/Delete/Confirm Address",
|
|
||||||
is_auth_required=True,
|
|
||||||
is_event_required=True,
|
|
||||||
endpoint_function=address_list,
|
|
||||||
),
|
|
||||||
EndpointFactoryConfig(
|
|
||||||
url_prefix=prefix,
|
|
||||||
url_endpoint="/create",
|
|
||||||
url_of_endpoint=f"{prefix}/create",
|
|
||||||
endpoint="/create",
|
|
||||||
method="POST",
|
|
||||||
summary="Create Address with given auth levels",
|
|
||||||
description="Create Address with given auth levels",
|
|
||||||
is_auth_required=False,
|
|
||||||
is_event_required=False,
|
|
||||||
endpoint_function=address_create,
|
|
||||||
),
|
|
||||||
EndpointFactoryConfig(
|
|
||||||
url_prefix=prefix,
|
|
||||||
url_endpoint="/{address_uu_id}",
|
|
||||||
url_of_endpoint="{prefix}/" + "{address_uu_id}",
|
|
||||||
endpoint="/{address_uu_id}",
|
|
||||||
method="PUT",
|
|
||||||
summary="Update Address with given auth levels",
|
|
||||||
description="Update Address with given auth levels",
|
|
||||||
is_auth_required=True,
|
|
||||||
is_event_required=True,
|
|
||||||
endpoint_function=address_update,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).as_dict()
|
|
||||||
157
Events/AllEvents/events/address/function_handlers.py
Normal file
157
Events/AllEvents/events/address/function_handlers.py
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
from ApiLayers.Schemas import AddressNeighborhood
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class AddressListFunctions(BaseRouteModel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def template_example_function_list(
|
||||||
|
cls, data: Optional[Union[dict, ListOptions]]
|
||||||
|
) -> PaginationResult:
|
||||||
|
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 AddressCreateFunctions(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 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
|
||||||
77
Events/AllEvents/events/address/info.py
Normal file
77
Events/AllEvents/events/address/info.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
from .address import (
|
||||||
|
AddressListEventMethods,
|
||||||
|
AddressCreateEventMethods,
|
||||||
|
AddressUpdateEventMethods,
|
||||||
|
AddressSearchEventMethods,
|
||||||
|
)
|
||||||
|
|
||||||
|
prefix = "/address"
|
||||||
|
cluster_name = "AddressCluster"
|
||||||
|
address_page_info = PageInfo(
|
||||||
|
name=f"{cluster_name}",
|
||||||
|
url=f"/dashboard?site={cluster_name}",
|
||||||
|
icon="Building",
|
||||||
|
endpoints={
|
||||||
|
str(
|
||||||
|
f"{prefix}{AddressUpdateEventMethods.URL}"
|
||||||
|
): AddressUpdateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(
|
||||||
|
f"{prefix}{AddressCreateEventMethods.URL}"
|
||||||
|
): AddressCreateEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(
|
||||||
|
f"{prefix}{AddressSearchEventMethods.URL}"
|
||||||
|
): AddressSearchEventMethods.retrieve_all_event_keys(),
|
||||||
|
str(
|
||||||
|
f"{prefix}{AddressListEventMethods.URL}"
|
||||||
|
): AddressListEventMethods.retrieve_all_event_keys(),
|
||||||
|
},
|
||||||
|
language_models={
|
||||||
|
"page_info": {
|
||||||
|
"key": "pair", # key: pair, value: dict
|
||||||
|
"description": {
|
||||||
|
"en": "Account Records for reaching user all types account information",
|
||||||
|
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
f"{prefix}{AddressUpdateEventMethods.URL}": {
|
||||||
|
"component": "Button",
|
||||||
|
"site_url": f"/update?site={cluster_name}",
|
||||||
|
"page_info": {
|
||||||
|
"text": {
|
||||||
|
"en": "Update Account Records",
|
||||||
|
"tr": "Hesap Kayıdı Güncelle",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
f"{prefix}{AddressCreateEventMethods.URL}": {
|
||||||
|
"component": "Button",
|
||||||
|
"site_url": f"/create?site={cluster_name}",
|
||||||
|
"page_info": {
|
||||||
|
"text": {
|
||||||
|
"en": "Create Account Records",
|
||||||
|
"tr": "Hesap Kayıdı Oluştur",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
f"{prefix}{AddressSearchEventMethods.URL}": {
|
||||||
|
"component": "Search",
|
||||||
|
"page_info": {
|
||||||
|
"text": {
|
||||||
|
"en": "Search Account Records",
|
||||||
|
"tr": "Hesap Kayıtlarını Ara",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
f"{prefix}{AddressListEventMethods.URL}": {
|
||||||
|
"component": "Table",
|
||||||
|
"fetch_url": AddressListEventMethods.URL,
|
||||||
|
"page_info": {
|
||||||
|
"description": {
|
||||||
|
"en": "Account Records for reaching user all types account information",
|
||||||
|
"tr": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/building/build_area/api_events.py
Normal file
21
Events/AllEvents/events/building/build_area/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/building/build_area/cluster.py
Normal file
14
Events/AllEvents/events/building/build_area/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/building/build_area/info.py
Normal file
11
Events/AllEvents/events/building/build_area/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/building/build_parts/api_events.py
Normal file
21
Events/AllEvents/events/building/build_parts/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/building/build_parts/cluster.py
Normal file
14
Events/AllEvents/events/building/build_parts/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/building/build_parts/info.py
Normal file
11
Events/AllEvents/events/building/build_parts/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/building/build_sites/api_events.py
Normal file
21
Events/AllEvents/events/building/build_sites/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/building/build_sites/cluster.py
Normal file
14
Events/AllEvents/events/building/build_sites/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/building/build_sites/info.py
Normal file
11
Events/AllEvents/events/building/build_sites/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/building/build_types/api_events.py
Normal file
21
Events/AllEvents/events/building/build_types/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/building/build_types/cluster.py
Normal file
14
Events/AllEvents/events/building/build_types/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/building/build_types/info.py
Normal file
11
Events/AllEvents/events/building/build_types/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
25
Events/AllEvents/events/building/building/api_events.py
Normal file
25
Events/AllEvents/events/building/building/api_events.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
# from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
building_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
# request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
statics="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
building_event.endpoint_callable = TemplateFunctions.template_example_function_list
|
||||||
|
|
||||||
|
|
||||||
|
class BuildingSuperUserEvents:
|
||||||
|
BuildingEvent = building_event
|
||||||
58
Events/AllEvents/events/building/building/building.py
Normal file
58
Events/AllEvents/events/building/building/building.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
"""
|
||||||
|
Account related API endpoints.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Any, Dict
|
||||||
|
from fastapi import Request
|
||||||
|
|
||||||
|
from Events.Engine.abstract_class import MethodToEvent
|
||||||
|
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
||||||
|
|
||||||
|
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||||
|
from ApiLayers.ApiValidations.Response.default_response import (
|
||||||
|
EndpointSuccessListResponse,
|
||||||
|
)
|
||||||
|
|
||||||
|
# from .function_handlers import (
|
||||||
|
# AddressListFunctions,
|
||||||
|
# AddressUpdateFunctions,
|
||||||
|
# AddressSearchFunctions,
|
||||||
|
# AddressCreateFunctions,
|
||||||
|
# )
|
||||||
|
from .api_events import BuildingSuperUserEvents
|
||||||
|
|
||||||
|
|
||||||
|
BuildingListEventMethods = MethodToEvent(
|
||||||
|
name="BuildingListEventMethods",
|
||||||
|
events={
|
||||||
|
BuildingSuperUserEvents.BuildingEvent.key: BuildingSuperUserEvents.BuildingEvent,
|
||||||
|
},
|
||||||
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def account_list_event_endpoint(
|
||||||
|
request: Request, data: EndpointBaseRequestModel
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||||
|
event_2_catch = BuildingListEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{BuildingSuperUserEvents.BuildingEvent.key}"
|
||||||
|
)
|
||||||
|
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||||
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
|
BuildingListFunctions.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()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
BuildingListEventMethods.endpoint_callable = account_list_event_endpoint
|
||||||
15
Events/AllEvents/events/building/building/cluster.py
Normal file
15
Events/AllEvents/events/building/building/cluster.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
|
||||||
|
from .info import building_page_info
|
||||||
|
|
||||||
|
|
||||||
|
BuildingCluster = CategoryCluster(
|
||||||
|
name="BuildingCluster",
|
||||||
|
tags=["Building"],
|
||||||
|
prefix="/building",
|
||||||
|
description="Building Cluster",
|
||||||
|
pageinfo=building_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
42
Events/AllEvents/events/building/building/info.py
Normal file
42
Events/AllEvents/events/building/building/info.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
from Events.Engine.abstract_class import PageComponent
|
||||||
|
|
||||||
|
|
||||||
|
create_building = PageComponent(
|
||||||
|
name="CreateBuilding",
|
||||||
|
url="/create",
|
||||||
|
language_models={
|
||||||
|
"en": "Create Building",
|
||||||
|
"tr": "Bina Oluştur",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
update_building = PageComponent(
|
||||||
|
name="UpdateBuilding",
|
||||||
|
url="/update",
|
||||||
|
language_models={
|
||||||
|
"en": "Update Building",
|
||||||
|
"tr": "Bina Güncelle",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
list_building = PageComponent(
|
||||||
|
name="ListBuilding",
|
||||||
|
url="/dashboard",
|
||||||
|
language_models={
|
||||||
|
"en": "List Building",
|
||||||
|
"tr": "Bina Listele",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
building_page_info = PageInfo(
|
||||||
|
name="BuildingCluster",
|
||||||
|
language_models={
|
||||||
|
"en": {},
|
||||||
|
"tr": {},
|
||||||
|
},
|
||||||
|
icon="Building",
|
||||||
|
sub_components=[create_building, update_building, list_building],
|
||||||
|
url="/dashboard?site=AddressCluster",
|
||||||
|
)
|
||||||
325
Events/AllEvents/events/building/building/models.py
Normal file
325
Events/AllEvents/events/building/building/models.py
Normal file
@@ -0,0 +1,325 @@
|
|||||||
|
"""
|
||||||
|
request models.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Dict, Any, Literal, Optional, TypedDict, Union
|
||||||
|
from pydantic import BaseModel, Field, model_validator, RootModel, ConfigDict
|
||||||
|
from ApiEvents.base_request_model import BaseRequestModel, DictRequestModel
|
||||||
|
from ApiValidations.Custom.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||||
|
from ApiValidations.Request.base_validations import ListOptions
|
||||||
|
from ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
||||||
|
from Schemas.identity.identity import (
|
||||||
|
AddressPostcode,
|
||||||
|
Addresses,
|
||||||
|
RelationshipEmployee2PostCode,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from fastapi import Request
|
||||||
|
|
||||||
|
|
||||||
|
class AddressListEventMethods(MethodToEvent):
|
||||||
|
|
||||||
|
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,
|
||||||
|
"52afe375-dd95-4f4b-aaa2-4ec61bc6de52": ListAddressResponse,
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 = [
|
||||||
|
street_id[0]
|
||||||
|
for street_id in AddressPostcode.select_only(
|
||||||
|
AddressPostcode.id.in_(post_code_id_list),
|
||||||
|
select_args=[AddressPostcode.street_id],
|
||||||
|
order_by=AddressPostcode.street_id.desc(),
|
||||||
|
).data
|
||||||
|
]
|
||||||
|
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),
|
||||||
|
).query
|
||||||
|
Addresses.filter_attr = list_options
|
||||||
|
records = Addresses.filter_all().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 AddressCreateEventMethods(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,
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 AddressSearchEventMethods(MethodToEvent):
|
||||||
|
"""Event methods for searching addresses.
|
||||||
|
|
||||||
|
This class handles address search functionality including text search
|
||||||
|
and filtering.
|
||||||
|
"""
|
||||||
|
|
||||||
|
event_type = "SEARCH"
|
||||||
|
event_description = "Search for addresses using text and filters"
|
||||||
|
event_category = "Address"
|
||||||
|
|
||||||
|
__event_keys__ = {
|
||||||
|
"e0ac1269-e9a7-4806-9962-219ac224b0d0": "search_address",
|
||||||
|
}
|
||||||
|
__event_validation__ = {
|
||||||
|
"e0ac1269-e9a7-4806-9962-219ac224b0d0": SearchAddress,
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _build_order_clause(
|
||||||
|
cls, filter_list: Dict[str, Any], schemas: List[str], filter_table: Any
|
||||||
|
) -> Any:
|
||||||
|
"""Build the ORDER BY clause for the query.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filter_list: Dictionary of filter options
|
||||||
|
schemas: List of available schema fields
|
||||||
|
filter_table: SQLAlchemy table to query
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SQLAlchemy order_by clause
|
||||||
|
"""
|
||||||
|
# Default to ordering by UUID if field not in schema
|
||||||
|
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:
|
||||||
|
record: Database record to format
|
||||||
|
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
|
||||||
|
def search_address(
|
||||||
|
cls,
|
||||||
|
data: SearchAddress,
|
||||||
|
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||||
|
) -> JSONResponse:
|
||||||
|
"""Search for addresses using text search and filters.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data: Search parameters including text and filters
|
||||||
|
token_dict: Authentication token
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
JSON response with search results
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
HTTPExceptionApi: If search fails
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Start performance measurement
|
||||||
|
start_time = perf_counter()
|
||||||
|
|
||||||
|
# Get initial query
|
||||||
|
search_result = AddressStreet.search_address_text(search_text=data.search)
|
||||||
|
if not search_result:
|
||||||
|
raise HTTPExceptionApi(
|
||||||
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
|
detail="No addresses found matching search criteria",
|
||||||
|
)
|
||||||
|
|
||||||
|
query = search_result.get("query")
|
||||||
|
schemas = search_result.get("schema")
|
||||||
|
|
||||||
|
# Apply filters
|
||||||
|
filter_list = data.list_options.dump()
|
||||||
|
filter_table = AddressStreet
|
||||||
|
|
||||||
|
# Build and apply order clause
|
||||||
|
order = cls._build_order_clause(filter_list, schemas, filter_table)
|
||||||
|
|
||||||
|
# Apply pagination
|
||||||
|
page_size = int(filter_list.get("size"))
|
||||||
|
offset = (int(filter_list.get("page")) - 1) * page_size
|
||||||
|
|
||||||
|
# Execute query
|
||||||
|
query = (
|
||||||
|
query.order_by(order)
|
||||||
|
.limit(page_size)
|
||||||
|
.offset(offset)
|
||||||
|
.populate_existing()
|
||||||
|
)
|
||||||
|
records = list(query.all())
|
||||||
|
|
||||||
|
# Format results
|
||||||
|
results = [cls._format_record(record, schemas) for record in records]
|
||||||
|
|
||||||
|
# Log performance
|
||||||
|
duration = perf_counter() - start_time
|
||||||
|
print(f"Address search completed in {duration:.3f}s")
|
||||||
|
|
||||||
|
return AlchemyJsonResponse(
|
||||||
|
completed=True, message="Address search results", result=results
|
||||||
|
)
|
||||||
|
|
||||||
|
except HTTPExceptionApi as e:
|
||||||
|
# Re-raise HTTP exceptions
|
||||||
|
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 AddressUpdateEventMethods(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,
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/building/living_spaces/api_events.py
Normal file
21
Events/AllEvents/events/building/living_spaces/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/building/living_spaces/cluster.py
Normal file
14
Events/AllEvents/events/building/living_spaces/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/building/living_spaces/info.py
Normal file
11
Events/AllEvents/events/building/living_spaces/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/company/api_events.py
Normal file
21
Events/AllEvents/events/company/company/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/company/cluster.py
Normal file
14
Events/AllEvents/events/company/company/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
78
Events/AllEvents/events/company/company/function_handlers.py
Normal file
78
Events/AllEvents/events/company/company/function_handlers.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/company/info.py
Normal file
11
Events/AllEvents/events/company/company/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/department/api_events.py
Normal file
21
Events/AllEvents/events/company/department/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/department/cluster.py
Normal file
14
Events/AllEvents/events/company/department/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/department/info.py
Normal file
11
Events/AllEvents/events/company/department/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/duties/api_events.py
Normal file
21
Events/AllEvents/events/company/duties/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/duties/cluster.py
Normal file
14
Events/AllEvents/events/company/duties/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
78
Events/AllEvents/events/company/duties/function_handlers.py
Normal file
78
Events/AllEvents/events/company/duties/function_handlers.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/duties/info.py
Normal file
11
Events/AllEvents/events/company/duties/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/duty/api_events.py
Normal file
21
Events/AllEvents/events/company/duty/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/duty/cluster.py
Normal file
14
Events/AllEvents/events/company/duty/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
78
Events/AllEvents/events/company/duty/function_handlers.py
Normal file
78
Events/AllEvents/events/company/duty/function_handlers.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/duty/info.py
Normal file
11
Events/AllEvents/events/company/duty/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/employee/api_events.py
Normal file
21
Events/AllEvents/events/company/employee/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/employee/cluster.py
Normal file
14
Events/AllEvents/events/company/employee/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/employee/info.py
Normal file
11
Events/AllEvents/events/company/employee/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
21
Events/AllEvents/events/company/staff/api_events.py
Normal file
21
Events/AllEvents/events/company/staff/api_events.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
14
Events/AllEvents/events/company/staff/cluster.py
Normal file
14
Events/AllEvents/events/company/staff/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
78
Events/AllEvents/events/company/staff/function_handlers.py
Normal file
78
Events/AllEvents/events/company/staff/function_handlers.py
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/company/staff/info.py
Normal file
11
Events/AllEvents/events/company/staff/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/decision_book/book_payment/info.py
Normal file
11
Events/AllEvents/events/decision_book/book_payment/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from Events.Engine.abstract_class import Event
|
||||||
|
from ApiLayers.LanguageModels.Request import (
|
||||||
|
LoginRequestLanguageModel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from models import TemplateResponseModels, TemplateRequestModels
|
||||||
|
from function_handlers import TemplateFunctions
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
template_event = Event(
|
||||||
|
name="authentication_login_super_user_event",
|
||||||
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
|
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||||
|
language_models=[LoginRequestLanguageModel],
|
||||||
|
response_validation_static="LOGIN_SUCCESS",
|
||||||
|
description="Login super user",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
template_event.endpoint_callable = TemplateFunctions.template_example_function()
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
from info import template_page_info
|
||||||
|
|
||||||
|
|
||||||
|
TemplateCluster = CategoryCluster(
|
||||||
|
name="TemplateCluster",
|
||||||
|
tags=["template"],
|
||||||
|
prefix="/template",
|
||||||
|
description="Template cluster",
|
||||||
|
pageinfo=template_page_info,
|
||||||
|
endpoints={},
|
||||||
|
include_in_schema=True,
|
||||||
|
sub_category=[],
|
||||||
|
)
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
|
class Handlers:
|
||||||
|
"""Class for handling authentication functions"""
|
||||||
|
|
||||||
|
@classmethod # Requires no auth context
|
||||||
|
def handle_function(cls, **kwargs):
|
||||||
|
"""Handle function with kwargs"""
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateFunctions(BaseRouteModel):
|
||||||
|
"""
|
||||||
|
Class for handling authentication functions
|
||||||
|
Is a template 4 TokenMiddleware.event_required decorator function groups.
|
||||||
|
results as :
|
||||||
|
STATIC_MESSAGE & LANG retrieved from redis
|
||||||
|
{
|
||||||
|
"completed": true,
|
||||||
|
"message": STATIC_MESSAGE,
|
||||||
|
"lang": LANG,
|
||||||
|
"pagination": {
|
||||||
|
"size": 10,
|
||||||
|
"page": 2,
|
||||||
|
"allCount": 28366,
|
||||||
|
"totalCount": 18,
|
||||||
|
"totalPages": 2,
|
||||||
|
"pageCount": 8,
|
||||||
|
"orderField": ["type_code", "neighborhood_name"],
|
||||||
|
"orderType": ["asc", "desc"]
|
||||||
|
},
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"uu_id": "e1baa3bc-93ce-4099-a078-a11b71d3b1a8"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@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),
|
||||||
|
)
|
||||||
11
Events/AllEvents/events/decision_book/decision_book/info.py
Normal file
11
Events/AllEvents/events/decision_book/decision_book/info.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
template_page_info = PageInfo(
|
||||||
|
name="template",
|
||||||
|
title={"en": "template"},
|
||||||
|
description={"en": "template"},
|
||||||
|
icon="",
|
||||||
|
parent="",
|
||||||
|
url="",
|
||||||
|
)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user