services are checked

This commit is contained in:
2024-11-08 17:14:02 +03:00
parent a5b1e0b2f4
commit c5b771e5cb
82 changed files with 1720 additions and 869 deletions

View File

@@ -4,7 +4,9 @@ from fastapi import status
from fastapi.responses import JSONResponse
from api_validations.validations_request import (
InsertCompanyDuty, PatchRecord, ListOptions
InsertCompanyDuty,
PatchRecord,
ListOptions,
)
from databases import Duty
@@ -23,7 +25,9 @@ class DutyListEventMethods(MethodToEvent):
@classmethod
def duty_list(
cls, list_options: ListOptions, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
cls,
list_options: ListOptions,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
records = Duty.filter_active(
*Duty.get_smart_query(list_options.query),
@@ -42,7 +46,9 @@ class DutyCreateEventMethods(MethodToEvent):
@classmethod
def duty_create(
cls, data: InsertCompanyDuty, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]
cls,
data: InsertCompanyDuty,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
created_duty = Duty.find_or_create(**data.excluded_dump())
Duty.save()
@@ -64,7 +70,12 @@ class DutyUpdateEventMethods(MethodToEvent):
}
@classmethod
def duty_update(cls, company_uu_id: str, data, token_dict: Union[EmployeeTokenObject, OccupantTokenObject]):
def duty_update(
cls,
company_uu_id: str,
data,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
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), # ?
@@ -104,9 +115,15 @@ class DutyPatchEventMethods(MethodToEvent):
)
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.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={