events updated
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
from api_validations.validations_request import (
|
||||
InsertDuties,
|
||||
UpdateDuties,
|
||||
@@ -32,12 +33,11 @@ class DutiesListEventMethods(MethodToEvent):
|
||||
records = Duties.filter_all(
|
||||
Duties.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return {
|
||||
"completed": True if records.count else False,
|
||||
"status": "success",
|
||||
"data": records.get_dict(),
|
||||
}
|
||||
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
result=records,
|
||||
message="List of Duties records",
|
||||
)
|
||||
|
||||
class DutiesGetByUUIDEventMethods(MethodToEvent):
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
|
||||
decision_book = BuildDecisionBook.filter_one(
|
||||
BuildDecisionBook.uu_id == data.build_decision_book_uu_id,
|
||||
*BuildDecisionBook.valid_record_args(BuildDecisionBook),
|
||||
)
|
||||
).data
|
||||
if not decision_book:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
@@ -55,7 +55,7 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
|
||||
Build.pre_query = Build.select_action(
|
||||
employee_id=token_dict.selected_company.employee_id,
|
||||
filter_expr=[
|
||||
Build.uu_id == decision_book.build_decision_book_uu_id,
|
||||
Build.uu_id == str(decision_book.uu_id),
|
||||
],
|
||||
)
|
||||
reachable_building = Build.filter_all()
|
||||
@@ -70,7 +70,7 @@ class DecisionBookDecisionBookItemsListEventMethods(MethodToEvent):
|
||||
token_dict.selected_company.duty_id,
|
||||
token_dict.selected_company.bulk_duties_id,
|
||||
],
|
||||
filter_expr=[Companies.id == decision_book.company_id],
|
||||
filter_expr=[Companies.id == decision_book.resp_company_id],
|
||||
)
|
||||
reachable_companies = Companies.filter_all()
|
||||
if not reachable_companies.data:
|
||||
|
||||
@@ -34,10 +34,13 @@ class UserListEventMethods(MethodToEvent):
|
||||
list_options: ListOptions,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
# Users.pre_query = Users.select_action(duty_id_list=[
|
||||
# token_dict.selected_company.duty_id,
|
||||
# token_dict.selected_company.bulk_duties_id
|
||||
# ])
|
||||
if isinstance(token_dict, OccupantTokenObject):
|
||||
raise Users.raise_http_exception(
|
||||
status_code="HTTP_403_FORBIDDEN",
|
||||
message="Occupant object can not list users",
|
||||
error_case="NOTAUTHORIZED",
|
||||
data={},
|
||||
)
|
||||
if "user_uu_id_list" in list_options.query:
|
||||
people_ids = list_options.query.pop("user_uu_id_list")
|
||||
people_id_list = (
|
||||
@@ -46,11 +49,11 @@ class UserListEventMethods(MethodToEvent):
|
||||
Users.uu_id.in_(people_ids), *Users.valid_record_args(Users)
|
||||
).data
|
||||
)
|
||||
People.filter_attr = list_options
|
||||
records = People.filter_all(
|
||||
People.id.in_(people_id_list),
|
||||
*People.valid_record_args(People),
|
||||
).data
|
||||
Users.filter_attr = list_options
|
||||
records = Users.filter_all(
|
||||
Users.person_id.in_(people_id_list),
|
||||
*Users.valid_record_args(Users),
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Users are listed successfully",
|
||||
@@ -59,7 +62,7 @@ class UserListEventMethods(MethodToEvent):
|
||||
Users.filter_attr = list_options
|
||||
records = Users.filter_all(
|
||||
*Users.valid_record_args(Users),
|
||||
).data
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Users are listed successfully",
|
||||
|
||||
Reference in New Issue
Block a user