database and services updated and tested
This commit is contained in:
0
api_events/events/company/__init__.py
Normal file
0
api_events/events/company/__init__.py
Normal file
189
api_events/events/company/company_company.py
Normal file
189
api_events/events/company/company_company.py
Normal file
@@ -0,0 +1,189 @@
|
||||
import typing
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from databases import Companies
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertCompany,
|
||||
UpdateCompany,
|
||||
ListOptions,
|
||||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
|
||||
|
||||
class CompanyListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"f6900cb5-ac5b-478e-8e7c-fa87e65cd2e5": "company_list",
|
||||
}
|
||||
__event_validation__ = {"f6900cb5-ac5b-478e-8e7c-fa87e65cd2e5": None}
|
||||
|
||||
@classmethod
|
||||
def company_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
if isinstance(token_dict, EmployeeTokenObject):
|
||||
Companies.pre_query = Companies.select_action(
|
||||
duty_id_list=[
|
||||
token_dict.selected_company.duty_id,
|
||||
token_dict.selected_company.bulk_duties_id,
|
||||
]
|
||||
)
|
||||
elif isinstance(token_dict, OccupantTokenObject):
|
||||
Companies.pre_query = Companies.filter_all(
|
||||
Companies.id == token_dict.selected_occupant.responsible_company_id
|
||||
).query
|
||||
Companies.filter_attr = list_options
|
||||
records = Companies.filter_all()
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Building Living Spaces are listed successfully",
|
||||
result=records,
|
||||
)
|
||||
|
||||
|
||||
class CompanyCreateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"76f11a08-5f4a-4e1f-961f-aaef21699acd": "company_create",
|
||||
}
|
||||
__event_validation__ = {"76f11a08-5f4a-4e1f-961f-aaef21699acd": InsertCompany}
|
||||
|
||||
@classmethod
|
||||
def company_create(
|
||||
cls,
|
||||
data: InsertCompany,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
created_company = Companies.create_action(data=data, token=token_dict)
|
||||
created_company.update(
|
||||
related_company=token_dict.selected_company.company_uu_id
|
||||
)
|
||||
created_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Company record",
|
||||
"data": created_company.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class CompanyUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"41ea7f29-006a-4310-b5c4-b2a0e1a504bd": "company_update",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"41ea7f29-006a-4310-b5c4-b2a0e1a504bd": UpdateCompany,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def company_update(
|
||||
cls, company_uu_id: str, data: UpdateCompany, token_dict: EmployeeTokenObject
|
||||
):
|
||||
Companies.pre_query = Companies.select_action(
|
||||
duty_id_list=[
|
||||
token_dict.selected_company.bulk_duties_id,
|
||||
token_dict.selected_company.duty_id,
|
||||
],
|
||||
)
|
||||
find_one_company = Companies.filter_one(
|
||||
Companies.uu_id == company_uu_id,
|
||||
).data
|
||||
if not find_one_company:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Company record",
|
||||
"data": {},
|
||||
},
|
||||
status_code=200,
|
||||
)
|
||||
updated_company = find_one_company.update(**data.excluded_dump())
|
||||
Companies.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Company record",
|
||||
"data": updated_company,
|
||||
},
|
||||
status_code=200,
|
||||
)
|
||||
|
||||
|
||||
class CompanyPatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"6320d696-1fd1-49f9-860a-8f22e5b8a68d": "company_patch",
|
||||
}
|
||||
__event_validation__ = {"6320d696-1fd1-49f9-860a-8f22e5b8a68d": None}
|
||||
|
||||
@classmethod
|
||||
def company_patch(
|
||||
cls, company_uu_id: str, data: PatchRecord, token_dict: EmployeeTokenObject
|
||||
):
|
||||
find_one_company = Companies.filter_one(
|
||||
Companies.uu_id == company_uu_id,
|
||||
).data
|
||||
access_authorized_company = Companies.select_action(
|
||||
duty_id_list=[
|
||||
token_dict.selected_company.bulk_duties_id,
|
||||
token_dict.selected_company.duty_id,
|
||||
],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_company.active = bool(
|
||||
action.get("active", find_one_company.active)
|
||||
)
|
||||
find_one_company.is_confirmed = bool(
|
||||
action.get("confirm", find_one_company.is_confirmed)
|
||||
)
|
||||
find_one_company.deleted = bool(
|
||||
action.get("delete", find_one_company.deleted)
|
||||
)
|
||||
find_one_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Company record completed",
|
||||
"data": find_one_company.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Company record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
CompanyPatchEventMethod = CompanyListEventMethods(
|
||||
action=ActionsSchema(endpoint="/company/list")
|
||||
)
|
||||
CompanyCreateEventMethod = CompanyCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/company/create")
|
||||
)
|
||||
CompanyUpdateEventMethod = CompanyUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/company/update")
|
||||
)
|
||||
CompanyListEventMethod = CompanyPatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/company/patch")
|
||||
)
|
||||
178
api_events/events/company/company_department.py
Normal file
178
api_events/events/company/company_department.py
Normal file
@@ -0,0 +1,178 @@
|
||||
from typing import Optional
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.validations_request import (
|
||||
DepartmentsPydantic,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
BaseModelRegular,
|
||||
)
|
||||
|
||||
from databases import Departments
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
|
||||
|
||||
class DepartmentListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"2cb90331-c1b4-4923-8314-8111326b621a": "department_list",
|
||||
}
|
||||
__event_validation__ = {"2cb90331-c1b4-4923-8314-8111326b621a": None}
|
||||
|
||||
@classmethod
|
||||
def department_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
Departments.filter_attr = list_options
|
||||
records = Departments.filter_all(
|
||||
Departments.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Departments are listed successfully",
|
||||
result=records,
|
||||
)
|
||||
|
||||
|
||||
class AdminUserInsertDepartments(BaseModelRegular):
|
||||
department_code: str
|
||||
department_name: str
|
||||
company_uu_id: Optional[str] = None
|
||||
|
||||
department_description: str
|
||||
parent_department_uu_id: Optional[int] = None
|
||||
|
||||
|
||||
class DepartmentCreateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"d8bd3985-7f3b-4267-a74e-d5017e4ea9f8": "super_user_department_create",
|
||||
}
|
||||
__event_validation__ = {"d8bd3985-7f3b-4267-a74e-d5017e4ea9f8": DepartmentsPydantic}
|
||||
|
||||
@classmethod
|
||||
def super_user_department_create(
|
||||
cls,
|
||||
data: DepartmentsPydantic,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
data_dict = data.excluded_dump()
|
||||
data_dict["company_id"] = token_dict.selected_company.company_id
|
||||
data_dict["company_uu_id"] = token_dict.selected_company.company_uu_id
|
||||
created_department = Departments.find_or_create(**data_dict)
|
||||
Departments.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Company record already exits here is the record",
|
||||
"data": created_department.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
|
||||
|
||||
class DepartmentUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"4172706f-06c9-4c38-9ac8-59085a72f80a": "department_update",
|
||||
}
|
||||
__event_validation__ = {"4172706f-06c9-4c38-9ac8-59085a72f80a": DepartmentsPydantic}
|
||||
|
||||
@classmethod
|
||||
def department_update(
|
||||
cls,
|
||||
company_uu_id: str,
|
||||
data: DepartmentsPydantic,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_company = Departments.filter_one(Departments.uu_id == company_uu_id)
|
||||
access_authorized_company = Departments.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Departments.id == token_dict.get("")],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_company = find_one_company.update(**data_dict)
|
||||
Departments.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Company record",
|
||||
"data": updated_company,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update Company record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class DepartmentPatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"1e272e4f-6c1e-418b-91a7-be8b06c875da": "department_patch",
|
||||
}
|
||||
__event_validation__ = {"1e272e4f-6c1e-418b-91a7-be8b06c875da": None}
|
||||
|
||||
@classmethod
|
||||
def department_patch(
|
||||
cls, company_uu_id: str, data: PatchRecord, token_dict: EmployeeTokenObject
|
||||
):
|
||||
find_one_company = Departments.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_company = Departments.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Departments.id == find_one_company.id],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_company.active = bool(
|
||||
action.get("active", find_one_company.active)
|
||||
)
|
||||
find_one_company.is_confirmed = bool(
|
||||
action.get("confirm", find_one_company.is_confirmed)
|
||||
)
|
||||
find_one_company.deleted = bool(
|
||||
action.get("delete", find_one_company.deleted)
|
||||
)
|
||||
find_one_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Company record completed",
|
||||
"data": find_one_company.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Company record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
DepartmentListEventMethod = DepartmentListEventMethods(
|
||||
action=ActionsSchema(endpoint="/department/list")
|
||||
)
|
||||
DepartmentCreateEventMethod = DepartmentCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/department/create")
|
||||
)
|
||||
DepartmentUpdateEventMethod = DepartmentUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/department/update")
|
||||
)
|
||||
DepartmentPatchEventMethod = DepartmentPatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/department/patch")
|
||||
)
|
||||
232
api_events/events/company/company_duties.py
Normal file
232
api_events/events/company/company_duties.py
Normal file
@@ -0,0 +1,232 @@
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
from api_validations.validations_request import (
|
||||
InsertDuties,
|
||||
UpdateDuties,
|
||||
SelectDuties,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Departments, Duty, Duties
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject
|
||||
|
||||
|
||||
class DutiesListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"44b72beb-53a8-407b-a12a-76e74b65794d": "duties_list",
|
||||
}
|
||||
__event_validation__ = {"44b72beb-53a8-407b-a12a-76e74b65794d": None}
|
||||
|
||||
@classmethod
|
||||
def duties_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
Duties.filter_attr = list_options
|
||||
records = Duties.filter_all(
|
||||
Duties.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
result=records,
|
||||
message="List of Duties records",
|
||||
)
|
||||
|
||||
|
||||
class DutiesGetByUUIDEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "GET"
|
||||
__event_keys__ = {
|
||||
"30c54cce-3303-4d36-959a-b64e383ae177": "duties_get_by_uuid",
|
||||
}
|
||||
__event_validation__ = {"30c54cce-3303-4d36-959a-b64e383ae177": SelectDuties}
|
||||
|
||||
@classmethod
|
||||
def duties_get_by_uuid(
|
||||
cls,
|
||||
data: SelectDuties,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
|
||||
duty = Duty.filter_one(Duty.uu_id == data.duty_uu_id).data
|
||||
if not duty:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Duty record is not found",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
|
||||
records = Duties.filter_all(
|
||||
Duties.duties_id == duty.id,
|
||||
Duties.company_id == token_dict.selected_company.company_id,
|
||||
)
|
||||
if not records.data:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Duties record is not found",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
return {
|
||||
"completed": True,
|
||||
"status": "success",
|
||||
"data": [record.get_dict() for record in records.data],
|
||||
}
|
||||
|
||||
|
||||
class DutiesCreateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"3524ae42-0825-4af7-be85-7c890a4f65d3": "duties_create",
|
||||
}
|
||||
__event_validation__ = {"3524ae42-0825-4af7-be85-7c890a4f65d3": InsertDuties}
|
||||
|
||||
@classmethod
|
||||
def duties_create(
|
||||
cls,
|
||||
data: InsertDuties,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
duty = Duty.filter_one(Duty.uu_id == data.duties_uu_id).data
|
||||
department = Departments.filter_one(Duty.uu_id == data.department_uu_id).data
|
||||
|
||||
created_duties = Duties.find_or_create(
|
||||
company_id=token_dict.selected_company.company_id,
|
||||
company_uu_id=token_dict.selected_company.company_uu_id,
|
||||
duties_id=duty.id,
|
||||
duties_uu_id=str(duty.uu_id),
|
||||
department_id=department.id,
|
||||
department_uu_id=str(department.uu_id),
|
||||
is_confirmed=data.is_confirmed,
|
||||
)
|
||||
if data.is_default_duty:
|
||||
created_duties.update(users_default_duty=created_duties.id)
|
||||
|
||||
if not created_duties:
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Failed to create Duties record",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
return {
|
||||
"completed": created_duties.is_found,
|
||||
"message": (
|
||||
"Create Duties record"
|
||||
if created_duties.is_found
|
||||
else "This record is already created"
|
||||
),
|
||||
"data": created_duties.get_dict(),
|
||||
}
|
||||
|
||||
|
||||
class DutiesUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"3fc77829-f1ee-4511-a2ca-582daa03125b": "duties_update",
|
||||
}
|
||||
__event_validation__ = {"3fc77829-f1ee-4511-a2ca-582daa03125b": UpdateDuties}
|
||||
|
||||
@classmethod
|
||||
def duties_update(
|
||||
cls,
|
||||
duties_uu_id: str,
|
||||
data: UpdateDuties,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_duties = Duties.find_one_or_abort(uu_id=duties_uu_id)
|
||||
access_authorized_duties = Duties.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Duties.id == find_one_duties.id],
|
||||
)
|
||||
if access_authorized_duties.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_duties = find_one_duties.update(**data_dict)
|
||||
Duties.save()
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Update Duties record",
|
||||
"data": updated_duties,
|
||||
}
|
||||
return {
|
||||
"completed": False,
|
||||
"message": "Update Duties record failed",
|
||||
"data": {},
|
||||
}
|
||||
|
||||
|
||||
class DutiesPatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"ca81c6d1-975a-4288-a27b-1069aea84afe": "duties_patch",
|
||||
}
|
||||
__event_validation__ = {"ca81c6d1-975a-4288-a27b-1069aea84afe": None}
|
||||
|
||||
@classmethod
|
||||
def duties_patch(
|
||||
cls,
|
||||
duties_uu_id: str,
|
||||
data: PatchRecord,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_duties = Duties.find_one_or_abort(uu_id=duties_uu_id)
|
||||
access_authorized_duties = Duties.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Duties.id == find_one_duties.id],
|
||||
)
|
||||
if access_authorized_duties.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_duties.active = bool(action.get("active", find_one_duties.active))
|
||||
find_one_duties.is_confirmed = bool(
|
||||
action.get("confirm", find_one_duties.is_confirmed)
|
||||
)
|
||||
find_one_duties.deleted = bool(
|
||||
action.get("delete", find_one_duties.deleted)
|
||||
)
|
||||
find_one_duties.save()
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Patch Duties record completed",
|
||||
"data": find_one_duties.get_dict(),
|
||||
}
|
||||
return {
|
||||
"completed": False,
|
||||
"message": "Patch Duties record failed",
|
||||
"data": {},
|
||||
}
|
||||
|
||||
|
||||
DutiesListEventMethod = DutiesListEventMethods(
|
||||
action=ActionsSchema(endpoint="/duties/list")
|
||||
)
|
||||
DutiesGetByUUIDEventMethod = DutiesGetByUUIDEventMethods(
|
||||
action=ActionsSchema(endpoint="/duties/get_by_duty_uuid")
|
||||
)
|
||||
DutiesCreateEventMethod = DutiesCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/duties/create")
|
||||
)
|
||||
DutiesUpdateEventMethod = DutiesUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/duties/update")
|
||||
)
|
||||
DutiesPatchEventMethod = DutiesPatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/duties/patch")
|
||||
)
|
||||
163
api_events/events/company/company_duty.py
Normal file
163
api_events/events/company/company_duty.py
Normal file
@@ -0,0 +1,163 @@
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertCompanyDuty,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Duty
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
|
||||
|
||||
class DutyListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"23231c7d-4ff2-4b39-b71b-ea350d31fadf": "duty_list",
|
||||
}
|
||||
__event_validation__ = {"23231c7d-4ff2-4b39-b71b-ea350d31fadf": None}
|
||||
|
||||
@classmethod
|
||||
def duty_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
Duty.filter_attr = list_options
|
||||
records = Duty.filter_all(system=True)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Duty list is brought successfully",
|
||||
result=records,
|
||||
)
|
||||
|
||||
|
||||
class DutyCreateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"c6ea200e-fa17-4393-b390-37f5337c9c65": "duty_create",
|
||||
}
|
||||
__event_validation__ = {"c6ea200e-fa17-4393-b390-37f5337c9c65": InsertCompanyDuty}
|
||||
|
||||
@classmethod
|
||||
def duty_create(
|
||||
cls,
|
||||
data: InsertCompanyDuty,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
created_duty = Duty.find_or_create(**data.excluded_dump())
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Company record",
|
||||
"data": created_duty.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class DutyUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"ad952647-bcf8-482d-9e05-b2ee8086483f": "duty_update",
|
||||
}
|
||||
__event_validation__ = {"ad952647-bcf8-482d-9e05-b2ee8086483f": None}
|
||||
|
||||
@classmethod
|
||||
def duty_update(
|
||||
cls,
|
||||
company_uu_id: str,
|
||||
data,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_company = Duty.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_company = Duty.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5), # ?
|
||||
filter_expr=[Duty.id == token_dict.get("")],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_company = find_one_company.update(**data_dict)
|
||||
Duty.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Company record",
|
||||
"data": updated_company,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update Company record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class DutyPatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"d5c7b5c4-7b4e-4d5b-8e3b-2b9c5f5d0c0b": "duty_patch",
|
||||
}
|
||||
__event_validation__ = {"d5c7b5c4-7b4e-4d5b-8e3b-2b9c5f5d0c0b": None}
|
||||
|
||||
@classmethod
|
||||
def duty_patch(
|
||||
cls,
|
||||
company_uu_id: str,
|
||||
data: PatchRecord,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_company = Duty.find_one_or_abort(uu_id=company_uu_id)
|
||||
access_authorized_company = Duty.select_action(
|
||||
duty_id=getattr(token_dict, "duty_id", 5),
|
||||
filter_expr=[Duty.id == find_one_company.id],
|
||||
)
|
||||
if access_authorized_company.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_company.active = bool(
|
||||
action.get("active", find_one_company.active)
|
||||
)
|
||||
find_one_company.is_confirmed = bool(
|
||||
action.get("confirm", find_one_company.is_confirmed)
|
||||
)
|
||||
find_one_company.deleted = bool(
|
||||
action.get("delete", find_one_company.deleted)
|
||||
)
|
||||
find_one_company.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Company record completed",
|
||||
"data": find_one_company.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Company record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
DutyListEventMethod = DutyListEventMethods(action=ActionsSchema(endpoint="/duty/list"))
|
||||
DutyCreateEventMethod = DutyCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/duty/create")
|
||||
)
|
||||
DutyUpdateEventMethod = DutyUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/duty/update")
|
||||
)
|
||||
DutyPatchEventMethod = DutyPatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/duty/patch")
|
||||
)
|
||||
343
api_events/events/company/company_employee.py
Normal file
343
api_events/events/company/company_employee.py
Normal file
@@ -0,0 +1,343 @@
|
||||
from fastapi import status, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_validations.validations_request import (
|
||||
InsertEmployees,
|
||||
BindEmployees2People,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Employees, Staff, People, EmployeeHistory
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
|
||||
|
||||
class EmployeeListEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"cb677c92-6b05-4122-af5c-12766fae8095": "employee_list",
|
||||
}
|
||||
__event_validation__ = {"cb677c92-6b05-4122-af5c-12766fae8095": None}
|
||||
|
||||
@classmethod
|
||||
def employee_list(
|
||||
cls,
|
||||
list_options: ListOptions,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
employees_staff = Staff.filter_all(
|
||||
Staff.duties_id.in_(token_dict.duty_id_list),
|
||||
).data
|
||||
Employees.filter_attr = list_options
|
||||
records = Employees.filter_all(
|
||||
Employees.staff_id.in_([staff.id for staff in employees_staff]),
|
||||
)
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Employee are listed successfully",
|
||||
result=records,
|
||||
)
|
||||
|
||||
|
||||
class EmployeeCreateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"1e1632c3-bb0e-46a5-8e45-da3f6d88ac43": "employee_create",
|
||||
}
|
||||
__event_validation__ = {"1e1632c3-bb0e-46a5-8e45-da3f6d88ac43": InsertEmployees}
|
||||
|
||||
@classmethod
|
||||
def employee_create(
|
||||
cls,
|
||||
data: InsertEmployees,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
person = People.filter_one(
|
||||
People.uu_id == data.people_uu_id,
|
||||
).data
|
||||
staff = Staff.filter_one(
|
||||
Staff.uu_id == data.staff_uu_id,
|
||||
).data
|
||||
if not staff:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Staff record not found",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
created_employee = Employees.find_or_create(
|
||||
staff_id=staff.id,
|
||||
staff_uu_id=str(staff.uu_id),
|
||||
people_id=person.id if person else None,
|
||||
people_uu_id=str(person.uu_id) if person else None,
|
||||
)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Employee record",
|
||||
"data": created_employee.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class EmployeeUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"9015a076-d78c-463d-9474-ea343a125fb8": "employee_update",
|
||||
}
|
||||
__event_validation__ = {"9015a076-d78c-463d-9474-ea343a125fb8": None}
|
||||
|
||||
@classmethod
|
||||
def employee_update(
|
||||
cls,
|
||||
employee_uu_id: str,
|
||||
data: PatchRecord,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_employee = Employees.filter_one(
|
||||
Employees.uu_id == employee_uu_id,
|
||||
).data
|
||||
access_authorized_employee = Employees.select_action(
|
||||
employee_id=getattr(token_dict, "employee_id", 5),
|
||||
filter_expr=[Employees.id == token_dict.get("")],
|
||||
)
|
||||
if access_authorized_employee.count:
|
||||
data_dict = data.excluded_dump()
|
||||
updated_employee = find_one_employee.update(**data_dict)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Update Employee record",
|
||||
"data": updated_employee,
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Update Employee record",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class EmployeePatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"8446ce0b-9310-4b9f-93e2-61f56a9dacd1": "employee_patch",
|
||||
}
|
||||
__event_validation__ = {"8446ce0b-9310-4b9f-93e2-61f56a9dacd1": None}
|
||||
|
||||
@classmethod
|
||||
def employee_patch(
|
||||
cls,
|
||||
employee_uu_id: str,
|
||||
data: PatchRecord,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
find_one_employee = Employees.find_one_or_abort(uu_id=employee_uu_id)
|
||||
access_authorized_employee = Employees.select_action(
|
||||
employee_id=getattr(token_dict, "employee_id", 5),
|
||||
filter_expr=[Employees.id == find_one_employee.id],
|
||||
)
|
||||
if access_authorized_employee.count:
|
||||
action = data.excluded_dump()
|
||||
find_one_employee.active = bool(
|
||||
action.get("active", find_one_employee.active)
|
||||
)
|
||||
find_one_employee.is_confirmed = bool(
|
||||
action.get("confirm", find_one_employee.is_confirmed)
|
||||
)
|
||||
find_one_employee.deleted = bool(
|
||||
action.get("delete", find_one_employee.deleted)
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Patch Employee record completed",
|
||||
"data": find_one_employee.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Employee record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class Employee2PeopleEmployEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"5eb04057-7a74-4555-b2c6-14eda32dae89": "company_employee_employ",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"5eb04057-7a74-4555-b2c6-14eda32dae89": BindEmployees2People
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def company_employee_employ(
|
||||
cls,
|
||||
data: BindEmployees2People,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
selected_staff = Staff.filter_one(
|
||||
Staff.uu_id == data.staff_uu_id,
|
||||
).data
|
||||
selected_people = People.filter_one(People.uu_id == data.people_uu_id).data
|
||||
if not selected_staff:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Staff record not found",
|
||||
)
|
||||
if not selected_people:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="People record not found",
|
||||
)
|
||||
|
||||
find_one_employee = Employees.filter_all(
|
||||
Employees.staff_id == selected_staff.id,
|
||||
).data
|
||||
|
||||
staff_name_upper = str(selected_staff.staff_name).upper()
|
||||
if not find_one_employee:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": f"There is no space for new Employee for given staff : {staff_name_upper}",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
)
|
||||
if not data.expiry_starts:
|
||||
data.expiry_starts = str(system_arrow.now())
|
||||
data.expiry_starts = str(system_arrow.get(str(data.expiry_starts)))
|
||||
|
||||
find_one_employee = find_one_employee.update(
|
||||
people_id=selected_people.id,
|
||||
expiry_starts=data.expiry_starts,
|
||||
**token_dict.update_creds,
|
||||
)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Get Employee to People record",
|
||||
"data": find_one_employee.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class Employee2PeopleFireEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"caf914fa-0899-4b0b-a85a-3d40fdaa06a5": "company_employee_fire",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"caf914fa-0899-4b0b-a85a-3d40fdaa06a5": BindEmployees2People
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def company_employee_fire(
|
||||
cls,
|
||||
data: BindEmployees2People,
|
||||
token_dict: EmployeeTokenObject,
|
||||
):
|
||||
selected_people = People.filter_one(
|
||||
People.uu_id == data.people_uu_id,
|
||||
).data
|
||||
if not selected_people:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="People record not found",
|
||||
)
|
||||
|
||||
find_one_employee: Employees = Employees.filter_one(
|
||||
Employees.people_id == selected_people.id,
|
||||
).data
|
||||
if not find_one_employee:
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Employee record not found for given People",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
|
||||
find_one_employee = find_one_employee.update(
|
||||
people_id=None, **token_dict.update_creds
|
||||
)
|
||||
if not find_one_employee.people_id:
|
||||
employee_history = EmployeeHistory.find_or_create(
|
||||
staff_id=find_one_employee.staff_id,
|
||||
expiry_ends=data.expiry_ends,
|
||||
people_id=selected_people.id,
|
||||
created_by_id=find_one_employee.created_by_id,
|
||||
updated_by_id=find_one_employee.updated_by_id,
|
||||
confirmed_by_id=find_one_employee.confirmed_by_id,
|
||||
replication_id=find_one_employee.replication_id,
|
||||
created_by=find_one_employee.created_by,
|
||||
updated_by=find_one_employee.updated_by,
|
||||
confirmed_by=find_one_employee.confirmed_by,
|
||||
active=find_one_employee.active,
|
||||
is_confirmed=find_one_employee.is_confirmed,
|
||||
deleted=find_one_employee.deleted,
|
||||
expiry_starts=find_one_employee.expiry_starts,
|
||||
is_notification_send=find_one_employee.is_notification_send,
|
||||
cryp_uu_id=find_one_employee.cryp_uu_id,
|
||||
)
|
||||
Employees.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Employee is fired from Staff",
|
||||
"data": find_one_employee.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Employee record not found for given People",
|
||||
)
|
||||
|
||||
|
||||
EmployeeListEventMethod = EmployeeListEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/list")
|
||||
)
|
||||
EmployeeCreateEventMethod = EmployeeCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/create")
|
||||
)
|
||||
EmployeeUpdateEventMethod = EmployeeUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/update")
|
||||
)
|
||||
EmployeePatchEventMethod = EmployeePatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/patch")
|
||||
)
|
||||
Employee2PeopleEmployEventMethod = Employee2PeopleEmployEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/employ")
|
||||
)
|
||||
Employee2PeopleFireEventMethod = Employee2PeopleFireEventMethods(
|
||||
action=ActionsSchema(endpoint="/employee/fire")
|
||||
)
|
||||
156
api_events/events/company/company_staff.py
Normal file
156
api_events/events/company/company_staff.py
Normal file
@@ -0,0 +1,156 @@
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertStaff,
|
||||
SelectStaff,
|
||||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import Staff, Duties
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject
|
||||
from api_validations.core_response import AlchemyJsonResponse
|
||||
|
||||
|
||||
class StaffListEventMethods(MethodToEvent):
|
||||
event_type = "SELECT"
|
||||
__event_keys__ = {
|
||||
"8984a519-99bf-4f25-8f34-2e1aebba468c": "staff_list",
|
||||
}
|
||||
__event_validation__ = {"8984a519-99bf-4f25-8f34-2e1aebba468c": None}
|
||||
|
||||
@classmethod
|
||||
def staff_list(cls, list_options: ListOptions, token_dict: EmployeeTokenObject):
|
||||
Staff.filter_attr = list_options
|
||||
records = Staff.filter_all()
|
||||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Staff are listed successfully",
|
||||
result=records,
|
||||
)
|
||||
|
||||
|
||||
class StaffCreateEventMethods(MethodToEvent):
|
||||
event_type = "CREATE"
|
||||
__event_keys__ = {
|
||||
"8f619257-19fd-404f-b713-7392c588dc36": "staff_create",
|
||||
}
|
||||
__event_validation__ = {"8f619257-19fd-404f-b713-7392c588dc36": InsertStaff}
|
||||
|
||||
@classmethod
|
||||
def staff_create(cls, data: InsertStaff, token_dict: EmployeeTokenObject):
|
||||
data_dict = data.excluded_dump()
|
||||
duties = Duties.filter_one(
|
||||
Duties.uu_id == data.duties_uu_id,
|
||||
).data
|
||||
if not duties:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Duties not found",
|
||||
)
|
||||
data_dict["duties_id"] = duties.id
|
||||
created_duty = Staff.find_or_create(**data_dict)
|
||||
Staff.save()
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Create Staff record",
|
||||
"data": created_duty.get_dict(),
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class StaffGetByUUIDEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "GET"
|
||||
__event_keys__ = {
|
||||
"7724cfbb-c0ee-4261-959b-61b84e88a34f": "staff_get_by_uu_id",
|
||||
}
|
||||
__event_validation__ = {"7724cfbb-c0ee-4261-959b-61b84e88a34f": SelectStaff}
|
||||
|
||||
@classmethod
|
||||
def staff_get_by_uu_id(cls, data: SelectStaff, token_dict: EmployeeTokenObject):
|
||||
if data.duties_uu_id:
|
||||
duties_id = Duties.filter_one(
|
||||
Duties.uu_id == data.duties_uu_id,
|
||||
).data
|
||||
selected_staffs = Staff.filter_all(Staff.duties_id == duties_id.id)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": True,
|
||||
"message": "Staff records are listed",
|
||||
"data": [
|
||||
selected_staff.get_dict()
|
||||
for selected_staff in selected_staffs.data
|
||||
],
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Get Staff record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
|
||||
|
||||
class StaffUpdateEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "UPDATE"
|
||||
__event_keys__ = {
|
||||
"5329f35d-ff9d-4656-a831-ba9c8204e483": "staff_update",
|
||||
}
|
||||
__event_validation__ = {"5329f35d-ff9d-4656-a831-ba9c8204e483": None}
|
||||
|
||||
@classmethod
|
||||
def staff_update(cls, staff_uu_id: str, data, token_dict: EmployeeTokenObject):
|
||||
return JSONResponse(
|
||||
content={"completed": True, "message": "Update Staff record", "data": {}},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class StaffPatchEventMethods(MethodToEvent):
|
||||
|
||||
event_type = "PATCH"
|
||||
__event_keys__ = {
|
||||
"b1cd7c0a-1458-472b-894f-3adc857c8512": "staff_patch",
|
||||
}
|
||||
__event_validation__ = {"b1cd7c0a-1458-472b-894f-3adc857c8512": None}
|
||||
|
||||
@classmethod
|
||||
def staff_patch(
|
||||
cls, staff_uu_id: str, data: PatchRecord, token_dict: EmployeeTokenObject
|
||||
):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"completed": False,
|
||||
"message": "Patch Staff record failed",
|
||||
"data": {},
|
||||
},
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
StaffListEventMethod = StaffListEventMethods(
|
||||
action=ActionsSchema(endpoint="/staff/list")
|
||||
)
|
||||
StaffCreateEventMethod = StaffCreateEventMethods(
|
||||
action=ActionsSchema(endpoint="/staff/create")
|
||||
)
|
||||
StaffGetByUUIDEventMethod = StaffGetByUUIDEventMethods(
|
||||
action=ActionsSchema(endpoint="/staff/get_by_duties_uu_id")
|
||||
)
|
||||
StaffUpdateEventMethod = StaffUpdateEventMethods(
|
||||
action=ActionsSchema(endpoint="/staff/update")
|
||||
)
|
||||
StaffPatchEventMethod = StaffPatchEventMethods(
|
||||
action=ActionsSchema(endpoint="/staff/patch")
|
||||
)
|
||||
Reference in New Issue
Block a user