events imports are checked
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
@@ -7,7 +9,7 @@ from databases import (
|
||||
Companies,
|
||||
)
|
||||
|
||||
from validations import InsertPerson, UpdateUsers
|
||||
from api_validations.validations_request import InsertPerson, UpdateUsers
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
@@ -26,8 +28,6 @@ class PeopleListEventMethods(MethodToEvent):
|
||||
|
||||
@classmethod
|
||||
def super_users_people_list(cls, list_options, token_dict):
|
||||
|
||||
|
||||
records = People.filter_active(
|
||||
*People.get_smart_query(smart_query=list_options.query)
|
||||
)
|
||||
@@ -58,9 +58,11 @@ class PeopleCreateEventMethods(MethodToEvent):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def people_create(cls, data: InsertPerson, token_dict: dict):
|
||||
|
||||
def people_create(
|
||||
cls, data: InsertPerson, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
created_user = People.create_action(data=data, token=token_dict)
|
||||
People.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
@@ -79,8 +81,9 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def people_update(cls, data: UpdateUsers, user_uu_id: str, token_dict: dict):
|
||||
|
||||
def people_update(
|
||||
cls, data: UpdateUsers, user_uu_id: str, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
):
|
||||
find_one_user = Users.find_one_or_abort(uu_id=user_uu_id)
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
@@ -89,6 +92,7 @@ class PeopleUpdateEventMethods(MethodToEvent):
|
||||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_user = find_one_user.update(**data_dict)
|
||||
Users.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
|
||||
Reference in New Issue
Block a user