events initated first endpoint tested
This commit is contained in:
parent
b664f64eb4
commit
9781cae858
|
|
@ -6,37 +6,31 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b5202e0c-6ddf-4a56-a13a-e18798c4c7cf" name="Changes" comment="">
|
<list default="true" id="b5202e0c-6ddf-4a56-a13a-e18798c4c7cf" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/AllConfigs/Redis/configs.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/AllConfigs/Redis/configs.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiServices/Token/token_handler.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiServices/Token/token_handler.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiValidations/Custom/token_objects.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiValidations/Custom/token_objects.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiValidations/Request/authentication.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiValidations/Request/authentication.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiValidations/Request/base_validations.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiValidations/Request/base_validations.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiValidations/Response/default_response.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiValidations/Response/default_response.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ApiLayers/ApiValidations/Response/default_response.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/ApiValidations/Response/default_response.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/LanguageModels/Request/Auth/login.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/Request/Auth/login.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ApiLayers/LanguageModels/Database/Mixins/crud_mixin.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/Database/Mixins/crud_mixin.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/LanguageModels/Response/authentication/auth.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/Response/authentication/auth.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ApiLayers/LanguageModels/Response/all_responses.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/Response/all_responses.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/LanguageModels/set_defaults/language_setters.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/set_defaults/language_setters.py" 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$/ApiLayers/LanguageModels/set_defaults/static_validation_retriever.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/LanguageModels/set_defaults/static_validation_retriever.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ApiLayers/Schemas/identity/identity.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/Schemas/identity/identity.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ApiLayers/Schemas/identity/identity.py" beforeDir="false" afterPath="$PROJECT_DIR$/ApiLayers/Schemas/identity/identity.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/DockerApiServices/AuthServiceApi/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/DockerApiServices/AuthServiceApi/config.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/DockerApiServices/EventServiceApi/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/DockerApiServices/EventServiceApi/Dockerfile" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/DockerApiServices/InitServiceApi/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/DockerApiServices/InitServiceApi/config.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/auth.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/auth.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/function_handlers.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/function_handlers.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/info.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/info.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/info.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/info.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/authentication/auth/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/__init__.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/__init__.py" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/account_records.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/template/template/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/template/template/api_events.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/template/template/info.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/template/template/info.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/cluster.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/cluster.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/template/template/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/template/template/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/endpoints.py" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/__init__.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/validations/validation/function_handlers.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/function_handlers.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/events/account/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/events/account/models.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/info.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/info.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" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/api_events.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/api_events.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/AllEvents/validations/validation/validation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/AllEvents/validations/validation/validation.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Events/Engine/abstract_class.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/Engine/abstract_class.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/Engine/abstract_class.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/Engine/abstract_class.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Events/Engine/set_defaults/setClusters.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/Engine/set_defaults/setClusters.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Events/base_request_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/Events/base_request_model.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/Models/filter_functions.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/Models/filter_functions.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/Models/crud_alchemy.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/Models/crud_alchemy.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/Models/pagination.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/Models/pagination.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/Models/pagination.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/Models/pagination.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/Models/response.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/Models/response.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/how_to.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/how_to.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Services/PostgresDb/how_to.py" beforeDir="false" afterPath="$PROJECT_DIR$/Services/PostgresDb/how_to.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/docker-compose-services.yml" beforeDir="false" afterPath="$PROJECT_DIR$/docker-compose-services.yml" 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" />
|
||||||
|
|
@ -68,11 +62,12 @@
|
||||||
"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/Events/AllEvents/events/account"
|
"last_opened_file_path": "/home/berkay/git-gitea-evyos/wag-managment-api-service-version-5/ApiLayers/ApiValidations/Queries"
|
||||||
}
|
}
|
||||||
}]]></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/account" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/events/account" />
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/validations/validation" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/validations/validation" />
|
||||||
<recent name="$PROJECT_DIR$/Events/AllEvents/template/template" />
|
<recent name="$PROJECT_DIR$/Events/AllEvents/template/template" />
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from ApiLayers.LanguageModels.set_defaults.static_validation_retriever import (
|
||||||
|
|
||||||
|
|
||||||
class BaseEndpointResponse(StaticValidationRetriever):
|
class BaseEndpointResponse(StaticValidationRetriever):
|
||||||
|
__abstract__ = True
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -20,6 +21,15 @@ class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class EndpointSuccessListResponse(BaseEndpointResponse): # 200 OK
|
||||||
|
|
||||||
|
def as_dict(self, data: Optional[dict] = None, pagination: Optional[dict] = None):
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=status.HTTP_200_OK,
|
||||||
|
content=dict(completed=True, **self.response, lang=self.lang, pagination=pagination, data=data),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
|
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
|
||||||
|
|
||||||
def as_dict(self, data: Optional[dict] = None):
|
def as_dict(self, data: Optional[dict] = None):
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ CrudCollectionLanguageModel = dict(
|
||||||
"active": "Aktif",
|
"active": "Aktif",
|
||||||
"is_notification_send": "Bildirim Gönderildi",
|
"is_notification_send": "Bildirim Gönderildi",
|
||||||
"is_email_send": "E-posta Gönderildi",
|
"is_email_send": "E-posta Gönderildi",
|
||||||
|
"expiry_ends": "Bitiş Tarihi",
|
||||||
|
"expiry_starts": "Başlangıç Tarihi",
|
||||||
},
|
},
|
||||||
en={
|
en={
|
||||||
"id": "Identity",
|
"id": "Identity",
|
||||||
|
|
@ -38,5 +40,7 @@ CrudCollectionLanguageModel = dict(
|
||||||
"active": "Active",
|
"active": "Active",
|
||||||
"is_notification_send": "Notification Sent",
|
"is_notification_send": "Notification Sent",
|
||||||
"is_email_send": "Email Sent",
|
"is_email_send": "Email Sent",
|
||||||
|
"expiry_ends": "Expiration End",
|
||||||
|
"expiry_starts": "Expiration Start",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
|
||||||
|
accountResponses = {
|
||||||
|
"ACCOUNTS_LIST": {
|
||||||
|
"tr": {
|
||||||
|
"message": "Hesap Bilgileri gönderilen sorgu ve filtreleme seçeneklerine göre başarılı bir şekilde listelendi.",
|
||||||
|
},
|
||||||
|
"en": {
|
||||||
|
"message": "Account Information listed successfully regarding to the sent query and filtering options.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ACCOUNT_CREATED": {
|
||||||
|
"tr": {
|
||||||
|
"message": "Hesap bilgileri başarılı bir şekilde eklendi.",
|
||||||
|
},
|
||||||
|
"en": {
|
||||||
|
"message": "Account information added successfully.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ACCOUNT_UPDATED": {
|
||||||
|
"tr": {
|
||||||
|
"message": "Hesap bilgileri başarılı bir şekilde güncellendi.",
|
||||||
|
},
|
||||||
|
"en": {
|
||||||
|
"message": "Account information updated successfully.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
from .authentication.auth import authResponses
|
from .authentication.auth import authResponses
|
||||||
|
from .accounts.accounts import accountResponses
|
||||||
|
|
||||||
all_response_list = [authResponses]
|
|
||||||
|
all_response_list = [authResponses, accountResponses]
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class TokenEventMiddleware:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def retrieve_intersected_event_code(
|
def retrieve_intersected_event_code(
|
||||||
request: Request, reachable_event_codes: list[str]
|
request: Request, reachable_event_codes: list[str]
|
||||||
) -> str:
|
) -> Tuple[str, str]:
|
||||||
"""
|
"""
|
||||||
Match an endpoint with accessible events.
|
Match an endpoint with accessible events.
|
||||||
|
|
||||||
|
|
@ -102,6 +102,7 @@ class TokenEventMiddleware:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Intersect function codes with user accers objects available event codes
|
# Intersect function codes with user accers objects available event codes
|
||||||
|
reachable_event_codes = ["36a165fe-a2f3-437b-80ee-1ee44670fe70"]
|
||||||
intersected_code = list(
|
intersected_code = list(
|
||||||
set(function_code_list_of_event) & set(reachable_event_codes)
|
set(function_code_list_of_event) & set(reachable_event_codes)
|
||||||
)
|
)
|
||||||
|
|
@ -133,9 +134,7 @@ class TokenEventMiddleware:
|
||||||
async def wrapper(request: Request, *args, **kwargs) -> Dict[str, Any]:
|
async def wrapper(request: Request, *args, **kwargs) -> Dict[str, Any]:
|
||||||
|
|
||||||
# Get and validate token context from request
|
# Get and validate token context from request
|
||||||
# token_context, reachable_event_codes = cls.retrieve_access_content(request)
|
token_context, reachable_event_codes = cls.retrieve_access_content(request)
|
||||||
reachable_event_codes = ["g1j8i6j7-9k4h-0h6l-4i3j-2j0k1k0j0i0k"]
|
|
||||||
token_context = {"token": "context", "context": {}}
|
|
||||||
endpoint_url, reachable_event_code = cls.retrieve_intersected_event_code(
|
endpoint_url, reachable_event_code = cls.retrieve_intersected_event_code(
|
||||||
request, reachable_event_codes
|
request, reachable_event_codes
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from sqlalchemy import (
|
||||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||||
|
|
||||||
from Services.PostgresDb import CrudCollection
|
from Services.PostgresDb import CrudCollection
|
||||||
# from config import ApiStatic
|
from config import ApiStatic
|
||||||
|
|
||||||
from ApiLayers.ApiLibrary.date_time_actions.date_functions import system_arrow
|
from ApiLayers.ApiLibrary.date_time_actions.date_functions import system_arrow
|
||||||
from ApiLayers.ApiLibrary.extensions.select import (
|
from ApiLayers.ApiLibrary.extensions.select import (
|
||||||
|
|
@ -204,7 +204,7 @@ class Users(CrudCollection, SelectAction):
|
||||||
return created_user
|
return created_user
|
||||||
|
|
||||||
def get_employee_and_duty_details(self):
|
def get_employee_and_duty_details(self):
|
||||||
from Schemas import Employees, Duties
|
from ApiLayers.Schemas import Employees, Duties
|
||||||
|
|
||||||
db_session = self.new_session()
|
db_session = self.new_session()
|
||||||
found_person = People.filter_one(
|
found_person = People.filter_one(
|
||||||
|
|
@ -244,7 +244,7 @@ class Users(CrudCollection, SelectAction):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_main_domain_and_other_domains(self, get_main_domain: bool = True):
|
def get_main_domain_and_other_domains(self, get_main_domain: bool = True):
|
||||||
from Schemas import MongoQueryIdentity
|
from ApiLayers.Schemas import MongoQueryIdentity
|
||||||
|
|
||||||
query_engine = MongoQueryIdentity(company_uuid=self.related_company)
|
query_engine = MongoQueryIdentity(company_uuid=self.related_company)
|
||||||
domain_via_user = query_engine.get_domain_via_user(user_uu_id=str(self.uu_id))
|
domain_via_user = query_engine.get_domain_via_user(user_uu_id=str(self.uu_id))
|
||||||
|
|
@ -391,7 +391,7 @@ class People(CrudCollection, SelectAction):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_action(cls, data: InsertPerson, token):
|
def create_action(cls, data: InsertPerson, token):
|
||||||
from Schemas import Duties
|
from ApiLayers.Schemas import Duties
|
||||||
|
|
||||||
token_duties_id, token_company_id = (
|
token_duties_id, token_company_id = (
|
||||||
token.selected_company.duty_id,
|
token.selected_company.duty_id,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ COPY ApiLayers /app/ApiLayers
|
||||||
COPY Services /app/Services
|
COPY Services /app/Services
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
# COPY Events/base_request_model.py /app/Events/base_request_model.py
|
|
||||||
COPY Events/Engine /app/Events/Engine
|
COPY Events/Engine /app/Events/Engine
|
||||||
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 Events/AllEvents/events /app/Events/AllEvents/events
|
COPY Events/AllEvents/events /app/Events/AllEvents/events
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ authentication_login_super_user_event = Event(
|
||||||
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||||
request_validator=AuthenticationRequestModels.LoginSuperUserRequestModel,
|
request_validator=AuthenticationRequestModels.LoginSuperUserRequestModel,
|
||||||
language_models=[LoginRequestLanguageModel],
|
language_models=[LoginRequestLanguageModel],
|
||||||
response_validation_static="LOGIN_SUCCESS",
|
statics="LOGIN_SUCCESS",
|
||||||
description="Login super user",
|
description="Login super user",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ authentication_select_super_user_event = Event(
|
||||||
key="f951ae1a-7950-4eab-ae2d-5bd9c2d21173",
|
key="f951ae1a-7950-4eab-ae2d-5bd9c2d21173",
|
||||||
request_validator=AuthenticationRequestModels.SelectCompanyOrOccupantTypeSuperUserRequestModel,
|
request_validator=AuthenticationRequestModels.SelectCompanyOrOccupantTypeSuperUserRequestModel,
|
||||||
language_models=[SelectRequestLanguageModel],
|
language_models=[SelectRequestLanguageModel],
|
||||||
response_validation_static="LOGIN_SELECT",
|
statics="LOGIN_SELECT",
|
||||||
description="Select company or occupant type super user",
|
description="Select company or occupant type super user",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
authentication_page_info = PageInfo(
|
authentication_page_info = PageInfo(
|
||||||
name="Authentication",
|
name="Authentication",
|
||||||
title={"en": "Authentication"},
|
title={"en": "Authentication", "tr": "Kimlik Doğrulama"},
|
||||||
description={"en": "Authentication"},
|
description={"en": "User&Event Authentication for users", "tr": "Kullanıcı ve Etkinlik Kimlik Doğrulama"},
|
||||||
icon="",
|
icon="",
|
||||||
parent="",
|
parent="",
|
||||||
url="",
|
url="",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
"""
|
"""
|
||||||
Events package initialization.
|
Events package initialization.
|
||||||
"""
|
"""
|
||||||
|
from .account.cluster import AccountCluster
|
||||||
|
|
||||||
__all__ = []
|
__all__ = [
|
||||||
|
"AccountCluster",
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
"""
|
|
||||||
Account records package initialization.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .endpoints import ACCOUNT_RECORDS_CONFIG
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
"ACCOUNT_RECORDS_CONFIG",
|
|
||||||
]
|
|
||||||
|
|
@ -1,39 +1,51 @@
|
||||||
"""
|
"""
|
||||||
template related API endpoints.
|
template 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 .account_records import template_event
|
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||||
|
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessListResponse
|
||||||
|
|
||||||
|
from .api_events import account_insert_super_user_event
|
||||||
|
from .function_handlers import AccountListEventMethods
|
||||||
|
|
||||||
|
|
||||||
AuthenticationLoginEventMethods = MethodToEvent(
|
AccountRecordsEventMethods = MethodToEvent(
|
||||||
name="AuthenticationLoginEventMethods",
|
name="AccountRecordsEventMethods",
|
||||||
events={
|
events={
|
||||||
template_event.key: template_event,
|
account_insert_super_user_event.key: account_insert_super_user_event,
|
||||||
},
|
},
|
||||||
headers=[],
|
headers=[],
|
||||||
errors=[],
|
errors=[],
|
||||||
url="/login",
|
decorators_list=[TokenEventMiddleware.event_required],
|
||||||
|
url="/list",
|
||||||
method="POST",
|
method="POST",
|
||||||
summary="Login via domain and access key : [email] | [phone]",
|
summary="Login via domain and access key : [email] | [phone]",
|
||||||
description="Login to the system via domain, access key : [email] | [phone]",
|
description="Login to the system via domain, access key : [email] | [phone]",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def authentication_login_with_domain_and_creds_endpoint(
|
def account_insert_event_endpoint(
|
||||||
request: Request, data: EndpointBaseRequestModel
|
request: Request, data: EndpointBaseRequestModel
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
event_2_catch = AuthenticationLoginEventMethods.retrieve_event(
|
context_retriever = ContextRetrievers(func=account_insert_event_endpoint)
|
||||||
event_function_code=f"{template_event.key}"
|
event_2_catch = AccountRecordsEventMethods.retrieve_event(
|
||||||
|
event_function_code=f"{account_insert_super_user_event.key}"
|
||||||
)
|
)
|
||||||
|
context_retriever.event = event_2_catch
|
||||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||||
return event_2_catch.endpoint_callable(request=request, data=data)
|
AccountListEventMethods.context_retriever = context_retriever
|
||||||
|
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||||
|
return EndpointSuccessListResponse(
|
||||||
|
code="ACCOUNTS_LIST", lang=context_retriever.token.lang
|
||||||
|
).as_dict(
|
||||||
|
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
AuthenticationLoginEventMethods.endpoint_callable = (
|
AccountRecordsEventMethods.endpoint_callable = (
|
||||||
authentication_login_with_domain_and_creds_endpoint
|
account_insert_event_endpoint
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
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 .models import AccountRequestValidators
|
||||||
|
from .function_handlers import (
|
||||||
|
AccountListEventMethods,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Auth Login
|
||||||
|
account_insert_super_user_event = Event(
|
||||||
|
name="account_insert_super_user_event",
|
||||||
|
key="36a165fe-a2f3-437b-80ee-1ee44670fe70",
|
||||||
|
request_validator=ListOptions,
|
||||||
|
# response_validator=SelectRequestLanguageModel,
|
||||||
|
# language_models=[AccountRecords.__language_model__],
|
||||||
|
language_models=[],
|
||||||
|
statics="ACCOUNTS_LIST",
|
||||||
|
description="List all types of accounts by validation list options and queries.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
account_insert_super_user_event.endpoint_callable = (
|
||||||
|
AccountListEventMethods.account_records_list
|
||||||
|
)
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
from Events.Engine.abstract_class import CategoryCluster
|
from Events.Engine.abstract_class import CategoryCluster
|
||||||
|
|
||||||
# from info import template_page_info
|
from .account_records import AccountRecordsEventMethods
|
||||||
|
from .info import account_page_info
|
||||||
|
|
||||||
|
|
||||||
AccountCluster = CategoryCluster(
|
AccountCluster = CategoryCluster(
|
||||||
name="AccountCluster",
|
name="AccountCluster",
|
||||||
tags=["template"],
|
tags=["accounts"],
|
||||||
prefix="/accounts",
|
prefix="/accounts",
|
||||||
description="Account Cluster",
|
description="Account Cluster",
|
||||||
pageinfo=None,
|
pageinfo=account_page_info,
|
||||||
endpoints={},
|
endpoints={
|
||||||
|
"AccountRecordsEventMethods": AccountRecordsEventMethods,
|
||||||
|
},
|
||||||
include_in_schema=True,
|
include_in_schema=True,
|
||||||
sub_category=[],
|
sub_category=[],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,131 +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("/account/records/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("/account/records/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("/account/records/search")
|
|
||||||
async def address_search(request: "Request", data: EndpointBaseRequestModel):
|
|
||||||
"""Handle address search endpoint."""
|
|
||||||
auth_dict = address_search.auth
|
|
||||||
code_dict = getattr(address_search, "func_code", {"function_code": None})
|
|
||||||
return {"auth_dict": auth_dict, "code_dict": code_dict, "data": data}
|
|
||||||
|
|
||||||
|
|
||||||
@endpoint_wrapper("/account/records/{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 = "/account/records"
|
|
||||||
|
|
||||||
# Account Records Router Configuration
|
|
||||||
ACCOUNT_RECORDS_CONFIG = RouteFactoryConfig(
|
|
||||||
name="account_records",
|
|
||||||
prefix=prefix,
|
|
||||||
tags=["Account Records"],
|
|
||||||
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="/search",
|
|
||||||
url_of_endpoint=f"{prefix}/search",
|
|
||||||
endpoint="/search",
|
|
||||||
method="POST",
|
|
||||||
summary="Search Address with given auth levels",
|
|
||||||
description="Search Address with given auth levels",
|
|
||||||
is_auth_required=True,
|
|
||||||
is_event_required=True,
|
|
||||||
endpoint_function=address_search,
|
|
||||||
),
|
|
||||||
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()
|
|
||||||
|
|
@ -2,253 +2,215 @@
|
||||||
Account records service implementation.
|
Account records service implementation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Union
|
from typing import Any, Union, Optional
|
||||||
from pydantic import Field
|
|
||||||
|
|
||||||
from Events.base_request_model import TokenDictType, BaseRouteModel
|
from ApiLayers.ApiLibrary import system_arrow
|
||||||
from ApiLayers.ApiValidations.Custom.token_objects import (
|
from ApiLayers.ApiValidations.Custom.token_objects import (
|
||||||
OccupantTokenObject,
|
OccupantTokenObject,
|
||||||
EmployeeTokenObject,
|
EmployeeTokenObject,
|
||||||
)
|
)
|
||||||
from ApiLayers.ApiLibrary import system_arrow
|
from ApiLayers.ApiValidations.Request import (
|
||||||
from ApiLayers.ApiValidations.Request.account_records import (
|
|
||||||
InsertAccountRecord,
|
InsertAccountRecord,
|
||||||
UpdateAccountRecord,
|
UpdateAccountRecord,
|
||||||
|
ListOptions,
|
||||||
)
|
)
|
||||||
from ApiLayers.ApiValidations.Request.base_validations import ListOptions
|
|
||||||
from ApiLayers.Schemas import (
|
from ApiLayers.Schemas import (
|
||||||
BuildLivingSpace,
|
BuildLivingSpace,
|
||||||
|
BuildDecisionBookPayments,
|
||||||
AccountRecords,
|
AccountRecords,
|
||||||
BuildIbans,
|
BuildIbans,
|
||||||
BuildDecisionBookPayments,
|
|
||||||
ApiEnumDropdown,
|
ApiEnumDropdown,
|
||||||
)
|
)
|
||||||
from Services.PostgresDb.Models.response import (
|
|
||||||
PostgresResponse,
|
|
||||||
)
|
|
||||||
from ApiLayers.ApiValidations.Response import AccountRecordResponse
|
from ApiLayers.ApiValidations.Response import AccountRecordResponse
|
||||||
from .models import (
|
|
||||||
InsertAccountRecordRequestModel,
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
UpdateAccountRecordRequestModel,
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
ListOptionsRequestModel,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AccountListEventMethod(BaseRouteModel):
|
class AccountListEventMethods(BaseRouteModel):
|
||||||
|
"""
|
||||||
event_type = "SELECT"
|
Account records list by with full privileges.
|
||||||
event_description = ""
|
Accepts List Options
|
||||||
event_category = ""
|
{
|
||||||
|
"data": {
|
||||||
__event_keys__ = {
|
"page": 1,
|
||||||
"7192c2aa-5352-4e36-98b3-dafb7d036a3d": "account_records_list",
|
"size": 10,
|
||||||
"208e6273-17ef-44f0-814a-8098f816b63a": "account_records_list_flt_res",
|
"order_field": ["uu_id",]
|
||||||
}
|
"order_type": ["desc"],
|
||||||
__event_validation__ = {
|
"query": {
|
||||||
"7192c2aa-5352-4e36-98b3-dafb7d036a3d": (
|
"process_date__gt": "2021-09-01",
|
||||||
AccountRecordResponse,
|
}
|
||||||
[AccountRecords.__language_model__],
|
}
|
||||||
),
|
}
|
||||||
"208e6273-17ef-44f0-814a-8098f816b63a": (
|
"""
|
||||||
AccountRecordResponse,
|
|
||||||
[AccountRecords.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def account_records_list(
|
def account_records_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
cls,
|
list_options_base = ListOptionsBase(
|
||||||
list_options: ListOptionsRequestModel,
|
table=AccountRecords, list_options=data, model_query=None,
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
)
|
||||||
):
|
db_session, query_options = list_options_base.init_list_options()
|
||||||
db_session = AccountRecords.new_session()
|
if cls.context_retriever.token.is_occupant:
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
|
||||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||||
AccountRecords.company_id
|
AccountRecords.company_id
|
||||||
== token_dict.selected_occupant.responsible_company_id,
|
== cls.context_retriever.token.selected_occupant.responsible_company_id,
|
||||||
db=db_session,
|
db=db_session,
|
||||||
).query
|
).query
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif cls.context_retriever.token.is_employee:
|
||||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||||
AccountRecords.company_id == token_dict.selected_company.company_id,
|
AccountRecords.company_id ==
|
||||||
|
cls.context_retriever.token.selected_company.company_id,
|
||||||
db=db_session,
|
db=db_session,
|
||||||
).query
|
).query
|
||||||
AccountRecords.filter_attr = list_options
|
records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
||||||
records = AccountRecords.filter_all(db=db_session)
|
return list_options_base.paginated_result(records=records)
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True,
|
# @classmethod
|
||||||
message="Account records listed successfully",
|
# def account_records_list_flt_res(cls, list_options: ListOptions) -> PaginationResult:
|
||||||
result=records,
|
# list_options_base = ListOptionsBase(
|
||||||
cls_object=AccountRecords,
|
# table=AccountRecords, list_options=list_options, model_query=None,
|
||||||
filter_attributes=list_options,
|
# )
|
||||||
response_model=AccountRecordResponse,
|
# db_session, query_options = list_options_base.init_list_options()
|
||||||
)
|
# if not cls.context_retriever.token.is_occupant:
|
||||||
|
# raise AccountRecords.raise_http_exception(
|
||||||
|
# status_code="HTTP_404_NOT_FOUND",
|
||||||
|
# error_case="UNAUTHORIZED",
|
||||||
|
# message="Only Occupant can see this data",
|
||||||
|
# data={},
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# return_list = []
|
||||||
|
# living_space: BuildLivingSpace = BuildLivingSpace.filter_by_one(
|
||||||
|
# id=cls.context_retriever.token.selected_occupant.living_space_id, db=db_session
|
||||||
|
# ).data
|
||||||
|
# if not living_space:
|
||||||
|
# raise AccountRecords.raise_http_exception(
|
||||||
|
# status_code="HTTP_404_NOT_FOUND",
|
||||||
|
# error_case="UNAUTHORIZED",
|
||||||
|
# message="Living space not found",
|
||||||
|
# data={},
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# if not list_options:
|
||||||
|
# list_options = ListOptions()
|
||||||
|
#
|
||||||
|
# main_filters = [
|
||||||
|
# AccountRecords.living_space_id
|
||||||
|
# == cls.context_retriever.token.selected_occupant.living_space_id,
|
||||||
|
# BuildDecisionBookPayments.process_date
|
||||||
|
# >= str(system_arrow.now().shift(months=-3).date()),
|
||||||
|
# BuildDecisionBookPayments.process_date
|
||||||
|
# < str(system_arrow.find_last_day_of_month(living_space.expiry_ends)),
|
||||||
|
# BuildDecisionBookPayments.process_date
|
||||||
|
# >= str(system_arrow.get(living_space.expiry_starts)),
|
||||||
|
# BuildDecisionBookPayments.is_confirmed == True,
|
||||||
|
# AccountRecords.active == True,
|
||||||
|
# ]
|
||||||
|
# order_type = "desc"
|
||||||
|
# if list_options.order_type:
|
||||||
|
# order_type = "asc" if list_options.order_type[0] == "a" else "desc"
|
||||||
|
#
|
||||||
|
# order_by_list = BuildDecisionBookPayments.process_date.desc()
|
||||||
|
# if list_options.order_field:
|
||||||
|
# if list_options.order_field == "process_date":
|
||||||
|
# order_by_list = (
|
||||||
|
# BuildDecisionBookPayments.process_date.asc()
|
||||||
|
# if order_type == "asc"
|
||||||
|
# else BuildDecisionBookPayments.process_date.desc()
|
||||||
|
# )
|
||||||
|
# if list_options.order_field == "bank_date":
|
||||||
|
# order_by_list = (
|
||||||
|
# AccountRecords.bank_date.desc()
|
||||||
|
# if order_type == "asc"
|
||||||
|
# else AccountRecords.bank_date.asc()
|
||||||
|
# )
|
||||||
|
# if list_options.order_field == "currency_value":
|
||||||
|
# order_by_list = (
|
||||||
|
# AccountRecords.currency_value.desc()
|
||||||
|
# if order_type == "asc"
|
||||||
|
# else AccountRecords.currency_value.asc()
|
||||||
|
# )
|
||||||
|
# if list_options.order_field == "process_comment":
|
||||||
|
# order_by_list = (
|
||||||
|
# AccountRecords.process_comment.desc()
|
||||||
|
# if order_type == "asc"
|
||||||
|
# else AccountRecords.process_comment.asc()
|
||||||
|
# )
|
||||||
|
# if list_options.order_field == "payment_amount":
|
||||||
|
# order_by_list = (
|
||||||
|
# BuildDecisionBookPayments.payment_amount.desc()
|
||||||
|
# if order_type == "asc"
|
||||||
|
# else BuildDecisionBookPayments.payment_amount.asc()
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# if list_options.query:
|
||||||
|
# for key, value in list_options.query.items():
|
||||||
|
# if key == "process_date":
|
||||||
|
# main_filters.append(BuildDecisionBookPayments.process_date == value)
|
||||||
|
# if key == "bank_date":
|
||||||
|
# main_filters.append(AccountRecords.bank_date == value)
|
||||||
|
# if key == "currency":
|
||||||
|
# main_filters.append(BuildDecisionBookPayments.currency == value)
|
||||||
|
# if key == "currency_value":
|
||||||
|
# main_filters.append(AccountRecords.currency_value == value)
|
||||||
|
# if key == "process_comment":
|
||||||
|
# main_filters.append(AccountRecords.process_comment == value)
|
||||||
|
# if key == "payment_amount":
|
||||||
|
# main_filters.append(
|
||||||
|
# BuildDecisionBookPayments.payment_amount == value
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# query = (
|
||||||
|
# AccountRecords.session.query(
|
||||||
|
# BuildDecisionBookPayments.process_date,
|
||||||
|
# BuildDecisionBookPayments.payment_amount,
|
||||||
|
# BuildDecisionBookPayments.currency,
|
||||||
|
# AccountRecords.bank_date,
|
||||||
|
# AccountRecords.currency_value,
|
||||||
|
# AccountRecords.process_comment,
|
||||||
|
# BuildDecisionBookPayments.uu_id,
|
||||||
|
# )
|
||||||
|
# .join(
|
||||||
|
# AccountRecords,
|
||||||
|
# AccountRecords.id == BuildDecisionBookPayments.account_records_id,
|
||||||
|
# )
|
||||||
|
# .filter(*main_filters)
|
||||||
|
# ).order_by(order_by_list)
|
||||||
|
#
|
||||||
|
# query.limit(list_options.size or 5).offset(
|
||||||
|
# (list_options.page or 1 - 1) * list_options.size or 5
|
||||||
|
# )
|
||||||
|
# for list_of_values in query.all() or []:
|
||||||
|
# return_list.append(
|
||||||
|
# {
|
||||||
|
# "process_date": list_of_values[0],
|
||||||
|
# "payment_amount": list_of_values[1],
|
||||||
|
# "currency": list_of_values[2],
|
||||||
|
# "bank_date": list_of_values[3],
|
||||||
|
# "currency_value": list_of_values[4],
|
||||||
|
# "process_comment": list_of_values[5],
|
||||||
|
# }
|
||||||
|
# )
|
||||||
|
# return AlchemyJsonResponse(
|
||||||
|
# completed=True,
|
||||||
|
# message="Account records listed successfully",
|
||||||
|
# result=return_list,
|
||||||
|
# cls_object=AccountRecords,
|
||||||
|
# filter_attributes=list_options,
|
||||||
|
# response_model=AccountRecordResponse,
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
class AccountCreateEventMethods(BaseRouteModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def account_records_list_flt_res(
|
def account_records_create(cls, data: Any):
|
||||||
cls,
|
|
||||||
list_options: ListOptionsRequestModel,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
db_session = AccountRecords.new_session()
|
|
||||||
if not isinstance(token_dict, OccupantTokenObject):
|
|
||||||
raise AccountRecords.raise_http_exception(
|
|
||||||
status_code="HTTP_404_NOT_FOUND",
|
|
||||||
error_case="UNAUTHORIZED",
|
|
||||||
message="Only Occupant can see this data",
|
|
||||||
data={},
|
|
||||||
)
|
|
||||||
|
|
||||||
return_list = []
|
|
||||||
living_space: BuildLivingSpace = BuildLivingSpace.filter_by_one(
|
|
||||||
id=token_dict.selected_occupant.living_space_id
|
|
||||||
).data
|
|
||||||
if not living_space:
|
|
||||||
raise AccountRecords.raise_http_exception(
|
|
||||||
status_code="HTTP_404_NOT_FOUND",
|
|
||||||
error_case="UNAUTHORIZED",
|
|
||||||
message="Living space not found",
|
|
||||||
data={},
|
|
||||||
)
|
|
||||||
|
|
||||||
if not list_options:
|
|
||||||
list_options = ListOptions()
|
|
||||||
|
|
||||||
main_filters = [
|
|
||||||
AccountRecords.living_space_id
|
|
||||||
== token_dict.selected_occupant.living_space_id,
|
|
||||||
BuildDecisionBookPayments.process_date
|
|
||||||
>= str(system_arrow.now().shift(months=-3).date()),
|
|
||||||
BuildDecisionBookPayments.process_date
|
|
||||||
< str(system_arrow.find_last_day_of_month(living_space.expiry_ends)),
|
|
||||||
BuildDecisionBookPayments.process_date
|
|
||||||
>= str(system_arrow.get(living_space.expiry_starts)),
|
|
||||||
BuildDecisionBookPayments.is_confirmed == True,
|
|
||||||
AccountRecords.active == True,
|
|
||||||
]
|
|
||||||
order_type = "desc"
|
|
||||||
if list_options.order_type:
|
|
||||||
order_type = "asc" if list_options.order_type[0] == "a" else "desc"
|
|
||||||
|
|
||||||
order_by_list = BuildDecisionBookPayments.process_date.desc()
|
|
||||||
if list_options.order_field:
|
|
||||||
if list_options.order_field == "process_date":
|
|
||||||
order_by_list = (
|
|
||||||
BuildDecisionBookPayments.process_date.asc()
|
|
||||||
if order_type == "asc"
|
|
||||||
else BuildDecisionBookPayments.process_date.desc()
|
|
||||||
)
|
|
||||||
if list_options.order_field == "bank_date":
|
|
||||||
order_by_list = (
|
|
||||||
AccountRecords.bank_date.desc()
|
|
||||||
if order_type == "asc"
|
|
||||||
else AccountRecords.bank_date.asc()
|
|
||||||
)
|
|
||||||
if list_options.order_field == "currency_value":
|
|
||||||
order_by_list = (
|
|
||||||
AccountRecords.currency_value.desc()
|
|
||||||
if order_type == "asc"
|
|
||||||
else AccountRecords.currency_value.asc()
|
|
||||||
)
|
|
||||||
if list_options.order_field == "process_comment":
|
|
||||||
order_by_list = (
|
|
||||||
AccountRecords.process_comment.desc()
|
|
||||||
if order_type == "asc"
|
|
||||||
else AccountRecords.process_comment.asc()
|
|
||||||
)
|
|
||||||
if list_options.order_field == "payment_amount":
|
|
||||||
order_by_list = (
|
|
||||||
BuildDecisionBookPayments.payment_amount.desc()
|
|
||||||
if order_type == "asc"
|
|
||||||
else BuildDecisionBookPayments.payment_amount.asc()
|
|
||||||
)
|
|
||||||
|
|
||||||
if list_options.query:
|
|
||||||
for key, value in list_options.query.items():
|
|
||||||
if key == "process_date":
|
|
||||||
main_filters.append(BuildDecisionBookPayments.process_date == value)
|
|
||||||
if key == "bank_date":
|
|
||||||
main_filters.append(AccountRecords.bank_date == value)
|
|
||||||
if key == "currency":
|
|
||||||
main_filters.append(BuildDecisionBookPayments.currency == value)
|
|
||||||
if key == "currency_value":
|
|
||||||
main_filters.append(AccountRecords.currency_value == value)
|
|
||||||
if key == "process_comment":
|
|
||||||
main_filters.append(AccountRecords.process_comment == value)
|
|
||||||
if key == "payment_amount":
|
|
||||||
main_filters.append(
|
|
||||||
BuildDecisionBookPayments.payment_amount == value
|
|
||||||
)
|
|
||||||
|
|
||||||
query = (
|
|
||||||
AccountRecords.session.query(
|
|
||||||
BuildDecisionBookPayments.process_date,
|
|
||||||
BuildDecisionBookPayments.payment_amount,
|
|
||||||
BuildDecisionBookPayments.currency,
|
|
||||||
AccountRecords.bank_date,
|
|
||||||
AccountRecords.currency_value,
|
|
||||||
AccountRecords.process_comment,
|
|
||||||
BuildDecisionBookPayments.uu_id,
|
|
||||||
)
|
|
||||||
.join(
|
|
||||||
AccountRecords,
|
|
||||||
AccountRecords.id == BuildDecisionBookPayments.account_records_id,
|
|
||||||
)
|
|
||||||
.filter(*main_filters)
|
|
||||||
).order_by(order_by_list)
|
|
||||||
|
|
||||||
query.limit(list_options.size or 5).offset(
|
|
||||||
(list_options.page or 1 - 1) * list_options.size or 5
|
|
||||||
)
|
|
||||||
for list_of_values in query.all() or []:
|
|
||||||
return_list.append(
|
|
||||||
{
|
|
||||||
"process_date": list_of_values[0],
|
|
||||||
"payment_amount": list_of_values[1],
|
|
||||||
"currency": list_of_values[2],
|
|
||||||
"bank_date": list_of_values[3],
|
|
||||||
"currency_value": list_of_values[4],
|
|
||||||
"process_comment": list_of_values[5],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return AlchemyJsonResponse(
|
|
||||||
completed=True,
|
|
||||||
message="Account records listed successfully",
|
|
||||||
result=return_list,
|
|
||||||
cls_object=AccountRecords,
|
|
||||||
filter_attributes=list_options,
|
|
||||||
response_model=AccountRecordResponse,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AccountCreateEventMethod(BaseRouteModel):
|
|
||||||
|
|
||||||
event_type = "CREATE"
|
|
||||||
event_description = ""
|
|
||||||
event_category = ""
|
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"31f4f32f-0cd4-4995-8a6a-f9f56335848a": "account_records_create",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"31f4f32f-0cd4-4995-8a6a-f9f56335848a": (
|
|
||||||
InsertAccountRecord,
|
|
||||||
[AccountRecords.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def account_records_create(
|
|
||||||
cls,
|
|
||||||
data: InsertAccountRecordRequestModel,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
data_dict = data.excluded_dump()
|
data_dict = data.excluded_dump()
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
db_session = AccountRecords.new_session()
|
||||||
db_session = AccountRecords.new_session()
|
if cls.context_retriever.token.is_occupant:
|
||||||
build_iban = BuildIbans.filter_one(
|
build_iban = BuildIbans.filter_one(
|
||||||
BuildIbans.iban == data.iban,
|
BuildIbans.iban == data.iban,
|
||||||
BuildIbans.build_id == token_dict.selected_occupant.build_id,
|
BuildIbans.build_id == cls.context_retriever.token.selected_occupant.build_id,
|
||||||
db=db_session,
|
db=db_session,
|
||||||
).data
|
).data
|
||||||
if not build_iban:
|
if not build_iban:
|
||||||
|
|
@ -256,17 +218,15 @@ class AccountCreateEventMethod(BaseRouteModel):
|
||||||
status_code="HTTP_404_NOT_FOUND",
|
status_code="HTTP_404_NOT_FOUND",
|
||||||
error_case="UNAUTHORIZED",
|
error_case="UNAUTHORIZED",
|
||||||
message=f"{data.iban} is not found in company related to your organization",
|
message=f"{data.iban} is not found in company related to your organization",
|
||||||
data={
|
data={"iban": data.iban},
|
||||||
"iban": data.iban,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
||||||
return AlchemyJsonResponse(
|
# return AlchemyJsonResponse(
|
||||||
completed=True,
|
# completed=True,
|
||||||
message="Account record created successfully",
|
# message="Account record created successfully",
|
||||||
result=account_record,
|
# result=account_record,
|
||||||
)
|
# )
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif cls.context_retriever.token.is_employee:
|
||||||
# Build.pre_query = Build.select_action(
|
# Build.pre_query = Build.select_action(
|
||||||
# employee_id=token_dict.selected_employee.employee_id,
|
# employee_id=token_dict.selected_employee.employee_id,
|
||||||
# )
|
# )
|
||||||
|
|
@ -293,58 +253,39 @@ class AccountCreateEventMethod(BaseRouteModel):
|
||||||
|
|
||||||
if int(data.currency_value) < 0:
|
if int(data.currency_value) < 0:
|
||||||
debit_type = ApiEnumDropdown.filter_by_one(
|
debit_type = ApiEnumDropdown.filter_by_one(
|
||||||
system=True, enum_class="DebitTypes", key="DT-D"
|
system=True, enum_class="DebitTypes", key="DT-D", db=db_session
|
||||||
).data
|
).data
|
||||||
data_dict["receive_debit"] = debit_type.id
|
data_dict["receive_debit"] = debit_type.id
|
||||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||||
else:
|
else:
|
||||||
debit_type = ApiEnumDropdown.filter_by_one(
|
debit_type = ApiEnumDropdown.filter_by_one(
|
||||||
system=True, enum_class="DebitTypes", key="DT-R"
|
system=True, enum_class="DebitTypes", key="DT-R", db=db_session
|
||||||
).data
|
).data
|
||||||
data_dict["receive_debit"] = debit_type.id
|
data_dict["receive_debit"] = debit_type.id
|
||||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||||
|
|
||||||
account_record = AccountRecords.insert_one(data_dict).data
|
account_record = AccountRecords.find_or_create(data_dict, db=db_session).data
|
||||||
return AlchemyJsonResponse(
|
# return AlchemyJsonResponse(
|
||||||
completed=True,
|
# completed=True,
|
||||||
message="Account record created successfully",
|
# message="Account record created successfully",
|
||||||
result=account_record,
|
# result=account_record,
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
class AccountUpdateEventMethod(BaseRouteModel):
|
class AccountUpdateEventMethods(BaseRouteModel):
|
||||||
|
|
||||||
event_type = "UPDATE"
|
|
||||||
event_description = ""
|
|
||||||
event_category = ""
|
|
||||||
|
|
||||||
__event_keys__ = {
|
|
||||||
"ec98ef2c-bcd0-432d-a8f4-1822a56c33b2": "account_records_update",
|
|
||||||
}
|
|
||||||
__event_validation__ = {
|
|
||||||
"ec98ef2c-bcd0-432d-a8f4-1822a56c33b2": (
|
|
||||||
UpdateAccountRecord,
|
|
||||||
[AccountRecords.__language_model__],
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def account_records_update(
|
def account_records_update(cls, build_uu_id: str, data: Any):
|
||||||
cls,
|
if cls.context_retriever.token.is_occupant:
|
||||||
build_uu_id: str,
|
|
||||||
data: UpdateAccountRecordRequestModel,
|
|
||||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
|
||||||
):
|
|
||||||
if isinstance(token_dict, OccupantTokenObject):
|
|
||||||
pass
|
pass
|
||||||
elif isinstance(token_dict, EmployeeTokenObject):
|
elif cls.context_retriever.token.is_employee:
|
||||||
pass
|
pass
|
||||||
AccountRecords.build_parts_id = token_dict.selected_occupant.build_part_id
|
AccountRecords.build_parts_id = cls.context_retriever.token.selected_occupant.build_part_id
|
||||||
account_record = AccountRecords.update_one(build_uu_id, data).data
|
account_record = AccountRecords.update_one(build_uu_id, data).data
|
||||||
return AlchemyJsonResponse(
|
# return AlchemyJsonResponse(
|
||||||
completed=True,
|
# completed=True,
|
||||||
message="Account record updated successfully",
|
# message="Account record updated successfully",
|
||||||
result=account_record,
|
# result=account_record,
|
||||||
cls_object=AccountRecords,
|
# cls_object=AccountRecords,
|
||||||
response_model=UpdateAccountRecord,
|
# response_model=UpdateAccountRecord,
|
||||||
)
|
# )
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
from Events.Engine.abstract_class import PageInfo
|
||||||
|
|
||||||
|
|
||||||
|
account_page_info = PageInfo(
|
||||||
|
name="Accounts",
|
||||||
|
title={"en": "Account Records", "tr": "Hesap Kayıtları"},
|
||||||
|
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="",
|
||||||
|
)
|
||||||
|
|
@ -2,53 +2,133 @@
|
||||||
Account records request and response models.
|
Account records request and response models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, Any
|
from typing import TYPE_CHECKING, Dict, Any, Optional
|
||||||
from pydantic import BaseModel, Field, RootModel
|
from pydantic import BaseModel
|
||||||
from ApiEvents.base_request_model import BaseRequestModel
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
from ApiLayers.ApiValidations.Request import PydanticBaseModel
|
||||||
from ApiValidations.Request import (
|
|
||||||
InsertAccountRecord,
|
|
||||||
UpdateAccountRecord,
|
|
||||||
ListOptions,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class AddressUpdateRequest(RootModel[Dict[str, Any]]):
|
class InsertAccountRecord(PydanticBaseModel):
|
||||||
"""Request model for address update."""
|
|
||||||
|
|
||||||
model_config = {
|
iban: str
|
||||||
"json_schema_extra": {
|
bank_date: str
|
||||||
"example": {
|
currency_value: float
|
||||||
"street": "123 Main St",
|
bank_balance: float
|
||||||
"city": "Example City",
|
currency: str
|
||||||
"country": "Example Country",
|
additional_balance: float
|
||||||
}
|
channel_branch: str
|
||||||
}
|
process_name: str
|
||||||
}
|
process_type: str
|
||||||
|
process_comment: str
|
||||||
|
bank_reference_code: str
|
||||||
|
|
||||||
|
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 AddressUpdateResponse(BaseModel):
|
class UpdateAccountRecord(PydanticBaseModel):
|
||||||
"""Response model for address update."""
|
|
||||||
|
|
||||||
address_uu_id: str = Field(..., description="UUID of the updated address")
|
iban: Optional[str] = None
|
||||||
data: Dict[str, Any] = Field(..., description="Updated address data")
|
bank_date: Optional[str] = None
|
||||||
function_code: str = Field(..., description="Function code for the endpoint")
|
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 InsertAccountRecordRequestModel(BaseRequestModel["InsertAccountRecord"]):
|
class ListAccountRecord(PydanticBaseModel):
|
||||||
"""Request model for inserting account records."""
|
|
||||||
|
|
||||||
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 UpdateAccountRecordRequestModel(BaseRequestModel["UpdateAccountRecord"]):
|
class AccountRequestValidators:
|
||||||
"""Request model for updating account records."""
|
InsertAccountRecord = InsertAccountRecord
|
||||||
|
UpdateAccountRecord = UpdateAccountRecord
|
||||||
pass
|
ListAccountRecord = ListAccountRecord
|
||||||
|
|
||||||
|
|
||||||
class ListOptionsRequestModel(BaseRequestModel["ListOptions"]):
|
|
||||||
"""Request model for list options."""
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
from typing import Any, Union
|
from typing import Union, Optional
|
||||||
from fastapi import Request
|
|
||||||
|
|
||||||
from Events.base_request_model import TokenDictType, BaseRouteModel
|
from ApiLayers.ApiValidations.Request import ListOptions
|
||||||
|
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||||
|
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||||
|
|
||||||
|
|
||||||
class Handlers:
|
class Handlers:
|
||||||
|
|
@ -14,8 +15,54 @@ class Handlers:
|
||||||
|
|
||||||
|
|
||||||
class TemplateFunctions(BaseRouteModel):
|
class TemplateFunctions(BaseRouteModel):
|
||||||
"""Class for handling authentication functions"""
|
"""
|
||||||
|
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
|
@classmethod
|
||||||
def template_example_function(cls):
|
def template_example_function_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||||
return
|
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)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ validation_event = Event(
|
||||||
key="02b5a596-14ba-4361-90d7-c6755727c63f",
|
key="02b5a596-14ba-4361-90d7-c6755727c63f",
|
||||||
request_validator=ValidationsPydantic,
|
request_validator=ValidationsPydantic,
|
||||||
language_models=[],
|
language_models=[],
|
||||||
response_validation_static=None,
|
statics=None,
|
||||||
description="Get Validations by event function code",
|
description="Get Validations by event function code",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class Event:
|
||||||
REQUEST_VALIDATOR: Optional[Any]
|
REQUEST_VALIDATOR: Optional[Any]
|
||||||
DESCRIPTION: str
|
DESCRIPTION: str
|
||||||
LANGUAGE_MODELS: list
|
LANGUAGE_MODELS: list
|
||||||
RESPONSE_VALIDATOR_STATIC: str
|
STATICS: str
|
||||||
EXTRA_OPTIONS: Optional[Dict[str, Any]] = None
|
EXTRA_OPTIONS: Optional[Dict[str, Any]] = None
|
||||||
endpoint_callable: Any
|
endpoint_callable: Any
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Event:
|
||||||
key: str | UUID,
|
key: str | UUID,
|
||||||
description: str,
|
description: str,
|
||||||
language_models: list[Dict[str, Dict]],
|
language_models: list[Dict[str, Dict]],
|
||||||
response_validation_static: str = None,
|
statics: str = None,
|
||||||
request_validator: Optional[Any] = None,
|
request_validator: Optional[Any] = None,
|
||||||
response_validator: Optional[Any] = None,
|
response_validator: Optional[Any] = None,
|
||||||
extra_options: Optional[Dict[str, Any]] = None,
|
extra_options: Optional[Dict[str, Any]] = None,
|
||||||
|
|
@ -56,14 +56,14 @@ class Event:
|
||||||
self.KEY_ = key
|
self.KEY_ = key
|
||||||
self.REQUEST_VALIDATOR = request_validator
|
self.REQUEST_VALIDATOR = request_validator
|
||||||
self.RESPONSE_VALIDATOR = response_validator
|
self.RESPONSE_VALIDATOR = response_validator
|
||||||
self.RESPONSE_VALIDATOR_STATIC = response_validation_static
|
self.STATICS = statics
|
||||||
self.LANGUAGE_MODELS = language_models
|
self.LANGUAGE_MODELS = language_models
|
||||||
self.DESCRIPTION = description
|
self.DESCRIPTION = description
|
||||||
self.EXTRA_OPTIONS = extra_options
|
self.EXTRA_OPTIONS = extra_options
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_static_response(self):
|
def is_static_response(self):
|
||||||
return bool(self.RESPONSE_VALIDATOR_STATIC)
|
return bool(self.STATICS)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def static_response(self):
|
def static_response(self):
|
||||||
|
|
@ -73,7 +73,7 @@ class Event:
|
||||||
if self.is_static_response:
|
if self.is_static_response:
|
||||||
static_response = RedisActions.get_json(
|
static_response = RedisActions.get_json(
|
||||||
list_keys=[
|
list_keys=[
|
||||||
f"{RedisValidationKeysAction.static_response_key}:{self.RESPONSE_VALIDATOR_STATIC}"
|
f"{RedisValidationKeysAction.static_response_key}:{self.STATICS}"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if static_response.status:
|
if static_response.status:
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ from ApiLayers.ApiValidations.Custom.token_objects import (
|
||||||
)
|
)
|
||||||
from ApiLayers.ApiValidations.Custom.wrapper_contexts import AuthContext, EventContext
|
from ApiLayers.ApiValidations.Custom.wrapper_contexts import AuthContext, EventContext
|
||||||
from ApiLayers.AllConfigs.Token.config import Auth
|
from ApiLayers.AllConfigs.Token.config import Auth
|
||||||
|
from Services.PostgresDb.Models.pagination import Pagination, PaginationResult, QueryOptions
|
||||||
|
|
||||||
|
|
||||||
TokenDictType = Union[EmployeeTokenObject, OccupantTokenObject]
|
TokenDictType = Union[EmployeeTokenObject, OccupantTokenObject]
|
||||||
|
|
@ -90,3 +91,24 @@ class ContextRetrievers:
|
||||||
class BaseRouteModel:
|
class BaseRouteModel:
|
||||||
|
|
||||||
context_retriever: Union[ContextRetrievers] = None
|
context_retriever: Union[ContextRetrievers] = None
|
||||||
|
|
||||||
|
|
||||||
|
class ListOptionsBase:
|
||||||
|
|
||||||
|
def __init__(self, table, list_options, model_query: Optional[BaseModel] = None):
|
||||||
|
self.table = table
|
||||||
|
self.list_options = list_options
|
||||||
|
self.model_query = model_query
|
||||||
|
|
||||||
|
def init_list_options(self) -> tuple:
|
||||||
|
db_session = self.table.new_session()
|
||||||
|
query_options = QueryOptions(table=self.table, data=self.list_options, model_query=self.model_query)
|
||||||
|
return db_session, query_options
|
||||||
|
|
||||||
|
def paginated_result(self, records) -> PaginationResult:
|
||||||
|
pagination = Pagination(data=records)
|
||||||
|
if isinstance(self.list_options, dict):
|
||||||
|
pagination.change(**self.list_options)
|
||||||
|
elif isinstance(self.list_options, BaseModel):
|
||||||
|
pagination.change(**self.list_options.model_dump())
|
||||||
|
return PaginationResult(data=records, pagination=pagination)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ class MetaDataRow(BaseModel):
|
||||||
class Credentials(BaseModel):
|
class Credentials(BaseModel):
|
||||||
person_id: int
|
person_id: int
|
||||||
person_name: str
|
person_name: str
|
||||||
|
full_name: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class CrudActions(SystemFields):
|
class CrudActions(SystemFields):
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ class Pagination:
|
||||||
"totalCount": self.total_count,
|
"totalCount": self.total_count,
|
||||||
"totalPages": self.total_pages,
|
"totalPages": self.total_pages,
|
||||||
"pageCount": self.page_count,
|
"pageCount": self.page_count,
|
||||||
"order_field": self.orderField,
|
"orderField": self.orderField,
|
||||||
"order_type": self.orderType,
|
"orderType": self.orderType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ adding convenience methods for accessing data and managing query state.
|
||||||
from typing import Any, Dict, Optional, TypeVar, Generic, Union
|
from typing import Any, Dict, Optional, TypeVar, Generic, Union
|
||||||
from sqlalchemy.orm import Query
|
from sqlalchemy.orm import Query
|
||||||
|
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,7 +17,6 @@ class PostgresResponse(Generic[T]):
|
||||||
Wrapper for PostgreSQL/SQLAlchemy query results.
|
Wrapper for PostgreSQL/SQLAlchemy query results.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
query: SQLAlchemy query object
|
|
||||||
metadata: Additional metadata for the query
|
metadata: Additional metadata for the query
|
||||||
|
|
||||||
Properties:
|
Properties:
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,14 @@ listing = True
|
||||||
creating = False
|
creating = False
|
||||||
updating = False
|
updating = False
|
||||||
|
|
||||||
|
|
||||||
new_session = AddressNeighborhood.new_session()
|
new_session = AddressNeighborhood.new_session()
|
||||||
new_session_test = AddressNeighborhood.new_session()
|
new_session_test = AddressNeighborhood.new_session()
|
||||||
|
|
||||||
|
|
||||||
BasicMixin.creds = Credentials(person_id=10, person_name="Berkay Super User")
|
BasicMixin.creds = Credentials(person_id=10, person_name="Berkay Super User")
|
||||||
|
|
||||||
|
|
||||||
class QueryModel(BaseModel):
|
class QueryModel(BaseModel):
|
||||||
neighborhood_name: Optional[str]
|
neighborhood_name: Optional[str]
|
||||||
neighborhood_code: Optional[str]
|
neighborhood_code: Optional[str]
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,14 @@ services:
|
||||||
dockerfile: DockerApiServices/ValidationServiceApi/Dockerfile
|
dockerfile: DockerApiServices/ValidationServiceApi/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "41577:41577"
|
- "41577:41577"
|
||||||
|
depends_on:
|
||||||
|
- init-service
|
||||||
|
|
||||||
# event-service:
|
event-service:
|
||||||
# build:
|
build:
|
||||||
# context: .
|
context: .
|
||||||
# dockerfile: DockerApiServices/EventServiceApi/Dockerfile
|
dockerfile: DockerApiServices/EventServiceApi/Dockerfile
|
||||||
# ports:
|
ports:
|
||||||
# - "41576:41576"
|
- "41576:41576"
|
||||||
# depends_on:
|
depends_on:
|
||||||
# - init-service
|
- init-service
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue