updated list options and response validatore tested
This commit is contained in:
@@ -44,26 +44,51 @@ class AccountListEventMethods(BaseRouteModel):
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
@classmethod
|
||||
def account_records_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||
from ApiLayers.Schemas import AddressNeighborhood
|
||||
list_options_base = ListOptionsBase(
|
||||
table=AccountRecords, list_options=data, model_query=None,
|
||||
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:
|
||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
AccountRecords.company_id
|
||||
== cls.context_retriever.token.selected_occupant.responsible_company_id,
|
||||
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||
AddressNeighborhood.neighborhood_code.icontains("10"),
|
||||
db=db_session,
|
||||
).query
|
||||
elif cls.context_retriever.token.is_employee:
|
||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
AccountRecords.company_id ==
|
||||
cls.context_retriever.token.selected_company.company_id,
|
||||
AddressNeighborhood.pre_query = AddressNeighborhood.filter_all(
|
||||
AddressNeighborhood.neighborhood_code.icontains("9"),
|
||||
db=db_session,
|
||||
).query
|
||||
records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
||||
return list_options_base.paginated_result(records=records)
|
||||
records = AddressNeighborhood.filter_all(*query_options.convert(), db=db_session)
|
||||
return list_options_base.paginated_result(
|
||||
records=records, response_model=cls.context_retriever.RESPONSE_VALIDATOR
|
||||
)
|
||||
|
||||
# @classmethod
|
||||
# def account_records_list(cls, data: Optional[Union[dict, ListOptions]]) -> PaginationResult:
|
||||
# list_options_base = ListOptionsBase(
|
||||
# table=AccountRecords, list_options=data, model_query=None,
|
||||
# )
|
||||
# db_session, query_options = list_options_base.init_list_options()
|
||||
# if cls.context_retriever.token.is_occupant:
|
||||
# AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
# AccountRecords.company_id
|
||||
# == cls.context_retriever.token.selected_occupant.responsible_company_id,
|
||||
# db=db_session,
|
||||
# ).query
|
||||
# elif cls.context_retriever.token.is_employee:
|
||||
# AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
# AccountRecords.company_id ==
|
||||
# cls.context_retriever.token.selected_company.company_id,
|
||||
# db=db_session,
|
||||
# ).query
|
||||
# records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
||||
# return list_options_base.paginated_result(
|
||||
# records=records, response_model=cls.context_retriever.RESPONSE_VALIDATOR
|
||||
# )
|
||||
|
||||
# @classmethod
|
||||
# def account_records_list_flt_res(cls, list_options: ListOptions) -> PaginationResult:
|
||||
|
||||
Reference in New Issue
Block a user