events cluster updated with PageInfo
This commit is contained in:
@@ -29,25 +29,29 @@ from Services.PostgresDb.Models.pagination import PaginationResult
|
||||
|
||||
class AccountListEventMethods(BaseRouteModel):
|
||||
"""
|
||||
Account records list by with full privileges.
|
||||
Accepts List Options
|
||||
{
|
||||
"data": {
|
||||
"page": 1,
|
||||
"size": 10,
|
||||
"order_field": ["uu_id",]
|
||||
"order_type": ["desc"],
|
||||
"query": {
|
||||
"process_date__gt": "2021-09-01",
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
Account records list by with full privileges.
|
||||
Accepts List Options
|
||||
{
|
||||
"data": {
|
||||
"page": 1,
|
||||
"size": 10,
|
||||
"order_field": ["uu_id",]
|
||||
"order_type": ["desc"],
|
||||
"query": {
|
||||
"process_date__gt": "2021-09-01",
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
@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(
|
||||
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()
|
||||
if cls.context_retriever.token.is_occupant:
|
||||
@@ -58,13 +62,14 @@ class AccountListEventMethods(BaseRouteModel):
|
||||
).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,
|
||||
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=getattr(cls.context_retriever, 'RESPONSE_VALIDATOR', None)
|
||||
records=records,
|
||||
response_model=getattr(cls.context_retriever, "RESPONSE_VALIDATOR", None),
|
||||
)
|
||||
|
||||
# @classmethod
|
||||
@@ -212,7 +217,8 @@ class AccountCreateEventMethods(BaseRouteModel):
|
||||
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,
|
||||
BuildIbans.build_id
|
||||
== cls.context_retriever.token.selected_occupant.build_id,
|
||||
db=db_session,
|
||||
).data
|
||||
if not build_iban:
|
||||
@@ -266,7 +272,9 @@ class AccountCreateEventMethods(BaseRouteModel):
|
||||
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
|
||||
account_record = AccountRecords.find_or_create(
|
||||
data_dict, db=db_session
|
||||
).data
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
# message="Account record created successfully",
|
||||
@@ -282,7 +290,9 @@ class AccountUpdateEventMethods(BaseRouteModel):
|
||||
pass
|
||||
elif cls.context_retriever.token.is_employee:
|
||||
pass
|
||||
AccountRecords.build_parts_id = cls.context_retriever.token.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
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
@@ -291,4 +301,3 @@ class AccountUpdateEventMethods(BaseRouteModel):
|
||||
# cls_object=AccountRecords,
|
||||
# response_model=UpdateAccountRecord,
|
||||
# )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user