error raise now locates loc
This commit is contained in:
@@ -86,7 +86,7 @@ class MethodToEvent(ABC, ActionsSchemaFactory):
|
||||
event_category: str = ""
|
||||
|
||||
__event_keys__: Dict[str, str] = {}
|
||||
__event_validation__: Dict[str, Any] = {}
|
||||
__event_validation__: list[Any, list[Any]] = []
|
||||
|
||||
@classmethod
|
||||
def call_event_method(cls, method_uu_id: str, *args: Any, **kwargs: Any) -> Any:
|
||||
@@ -106,7 +106,6 @@ class MethodToEvent(ABC, ActionsSchemaFactory):
|
||||
function_name = cls.__event_keys__.get(method_uu_id)
|
||||
if not function_name:
|
||||
raise AttributeError(f"No method found for UUID: {method_uu_id}")
|
||||
|
||||
return getattr(cls, function_name)(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
@@ -128,3 +127,22 @@ class MethodToEvent(ABC, ActionsSchemaFactory):
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
detail=f"No {user_type} can reach this event. A notification has been sent to admin.",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def retrieve_language_parameters(cls, language: str, function_code: str):
|
||||
|
||||
event_response_model = dict(cls.__event_validation__).get(function_code)[0]
|
||||
event_language_models = list(
|
||||
dict(cls.__event_validation__).get(function_code)[1]
|
||||
)
|
||||
language_models, language_response = {}, {}
|
||||
for event_language_model in event_language_models:
|
||||
language_models.update({**event_language_model.get(language, "tr")})
|
||||
from api_validations.validations_response.building_responses import (
|
||||
ListBuildingResponse,
|
||||
)
|
||||
|
||||
for model_field in event_response_model.model_fields:
|
||||
if model_field in language_models:
|
||||
language_response[model_field] = language_models[model_field]
|
||||
return language_response
|
||||
|
||||
@@ -18,10 +18,10 @@ from api_validations.validations_request import (
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
from api_validations.validations_response import BuildResponse
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.validations_response.building_responses import ListBuildingResponse
|
||||
|
||||
|
||||
class BuildListEventMethods(MethodToEvent):
|
||||
@@ -34,7 +34,10 @@ class BuildListEventMethods(MethodToEvent):
|
||||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": "build_list",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": BuildResponse,
|
||||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": (
|
||||
ListBuildingResponse,
|
||||
[Build.__language_model__],
|
||||
)
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -59,7 +62,7 @@ class BuildListEventMethods(MethodToEvent):
|
||||
result=records,
|
||||
cls_object=Build,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildResponse,
|
||||
response_model=ListBuildingResponse,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user